The Grey Labyrinth is a collection of puzzles, riddles, mind games, paradoxes and other intellectually challenging diversions. Related topics: puzzle games, logic puzzles, lateral thinking puzzles, philosophy, mind benders, brain teasers, word problems, conundrums, 3d puzzles, spatial reasoning, intelligence tests, mathematical diversions, paradoxes, physics problems, reasoning, math, science.

   
The Grey Labyrinth Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups    RegisterRegister  
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Who knows Lisp?

 
Reply to topic    The Grey Labyrinth Forum Index -> Off-Topic
View previous topic :: View next topic  
Author Message
extropalopakettle
No offense, but....



PostPosted: Sat Apr 20, 2013 7:57 am    Post subject: 1 Reply with quote

just curious

(I do)
Back to top
View user's profile Send private message
The Potter
Feat of Clay



PostPosted: Sat Apr 20, 2013 9:17 am    Post subject: 2 Reply with quote

A man walks into a toothbrush factory, and tells the owner..."Id like ta hath a job telling tootbrushes". The owner looks at him and replies..."I don't know if you are aware of it or not, but you have a serious speech impediment, and I don't see how you would be an effective salesman for this company". The man says "Pleath Just gib me a thance and Ill tho you whut I can do. The owner, thinking that he will get rid of him, tells him..."go to a salesman's school, graduate, and I'll give you a job"

A year later, the same man walks into the toothbrush factory, this time carrying a framed diploma, and declaring..."I'm theer about tha job The owner being a man of his word, gives him a job, He tells the new salesman that their best salesmen sell between 5 to 7 thousand toothbrushes a week.

The new salesman shows up the next week and sits dejectedly in the owners office, as the owner asks..."how many toothbrushes did you sell"?. The new salesman replies..."I told teven tootbrushes". The owner tells him if all he can sell is seven toothbrushes, then he will have to let him go.The new salesman pleads... "Pleath Just gib me a thance and Ill tho you whut I can do. The owner tells him that he will give him one more week.

The new salesman shows up the next week and sits in the owners office, as the owner asks..."how many toothbrushes did you sell"?. The new salesman replies..."I told thirtween thousand tootbrushes". The owners mouth drops, and he declares.."that's a new company record!!!, How did you sell that many toothbrushes?

The new salesman tells him.."come outt to tha air pirt and I'll tho ya ma thetup" The owner arrives at the airport and sees that the salesman has a big welcome sign, a big stack of toothbrushes, a big bowl of potato chips, and a big bowl of dip. The owner says..."I still dont see how you sold that man toothbrushes". The salesman tell him "twy a potato thip". the owner takes a potato chip, dips it, and takes a big bite. He immediately spits it out saying..."this tastes like shit!" New salesman replys..."ya it tis, wanna buy a tootbrush?"

---
oh, I don't know the programming language of lisp.
_________________
Artwork | Fractals | Don't ignore your dreams; don't work too much; say what you think; cultivate friendships; be happy.
Back to top
View user's profile Send private message
Jedo the Jedi
Paragon in Training



PostPosted: Sat Apr 20, 2013 10:17 am    Post subject: 3 Reply with quote

Haha. I haven't heard that joke since I was like 8. That's awesome.

I also have no idea about "Lisp."
_________________
Paragon Tally: 18 mafia, 3 SKs (1 twice), 1 cultist, numerous chat scum...and counting.
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
Trojan Horse
Daedalian Member



PostPosted: Sat Apr 20, 2013 2:10 pm    Post subject: 4 Reply with quote

I started learning Lisp about six months ago. My Lisp of choice: Racket. (In the Scheme vs. Common Lisp battle, Racket is on the Scheme side.)

It's nice to know that (cdr glers-who-know-lisp) is not the empty list. Extreme Delectation
Back to top
View user's profile Send private message Send e-mail
LordKinbote
Daedalian Member



PostPosted: Sat Apr 20, 2013 2:55 pm    Post subject: 5 Reply with quote

Trojan Horse wrote:
I started learning Lisp about six months ago. My Lisp of choice: Racket. (In the Scheme vs. Common Lisp battle, Racket is on the Scheme side.)

It's nice to know that (cdr glers-who-know-lisp) is not the empty list. Extreme Delectation


I thought Racket *was* Scheme. Am I wrong? (Edit: Turns out I am...Racket is to Scheme as Python 3 is to Python 2, I guess.)

Programming 101 at my college was taught with Scheme, and when I took Artificial Intelligence 3 years later, we used Lisp. Scheme was also the first language I ever taught my students (with mixed results) but now my language of choice for myself and for my students is Python.
Back to top
View user's profile Send private message
extropalopakettle
No offense, but....



PostPosted: Sat Apr 20, 2013 6:48 pm    Post subject: 6 Reply with quote

I first started learning Lisp from a series of three issues of Scientific American in the early 80s, in Douglas Hofstadter's "Metamagical Themas" section (the successor to Martin Gardner's "Mathematical Recreations"). I was interested in AI at the time ... and computation in general. From there I eventually went on to teaching Lisp (in a survey of programming languages course, along with Prolog, SNOBOL4 and C). I also was system administrator for 2 Symbolics Lisp Machines (took a week-long course at Symbolics in Boston (trivia: the companies domain name, symbolics.com, was the first domain name ever registered).

I love the language. It's one language I think you can never forget once learned. I'm also fairly adept at writing Lisp functions backwards (right to left, bottom to top) ... a fun party trick if it's the right crowd (but it seldom is).

It suspect it's also the easiest programming language to write an interpreter for.
Back to top
View user's profile Send private message
Zag
Tired of his old title



PostPosted: Sat Apr 20, 2013 7:27 pm    Post subject: 7 Reply with quote

LordKinbote wrote:
Programming 101 at my college was taught with Scheme.

Did you go to MIT? What a terrible, terrible choice for a Programming 101 language. And by 'terrible' I mean really awful, showing the worst combination of academic arrogance and real-world ignorance on the part of the Professors. Have I said this strongly enough, yet? There's a big place for Lisp/Scheme/whatever in academic Computer Science education. But 'Programming 101' isn't it.

Let me explain, a bit, why I react so strongly. I went to Northeastern University, a place which emphasizes a PRACTICAL engineering education. (That is, an education which equips you to go out into the real world and, you know, do stuff that is useful.) I have spent my entire 30-year career in software working in the greater Boston area (if you count that as stretching all the way up to Portsmouth, NH) and I have run into plenty of MIT "CS Theory" snobs who believe that if you graduated anywhere else, you're not worth talking to, and yet they can't code their way out of a paper bag.

I do realize that this doesn't represent everyone who graduated from "that school across the river" as people in Northeastern sometimes referred to it, not even the majority of them. But it does represent more than you'd think. The sort of arrogance that causes Professors to choose Scheme as the language for Programming 101 is the source of a lot of it.

I ran into one who thought that we should change our whole approach to the entire company's product, making it into something that is a thinly-veiled LISP/Scheme development environment -- completely different from what we were doing. When I and others pointed out that his idea, while perhaps representing a satisfying theoretical marriage of a Scheme-ish language applied to web development, does not solve our customers' problems, he pooh-poohed such unimportant trivialities. When, after having the idea quashed by upper management, he went so far as to bend the ear of a potential customer on the subject, which confused the customer enough that we lost him. Fortunately, this got him fired. I learned years later that he actually tried to make a company around his idea, and it went a whole lot of no where.

(By the way, this same guy once bragged to me that he was part of the MIT team that made millions of dollars playing blackjack in Las Vegas. I had heard about them but this was before the movie came out. However, in discussing blackjack with him, it was clear that he barely knew how to play, and he claimed that the success was from such techniques as "tracking the aces" through the deck. So he was a blowhard in general.)
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Quailman
His Postmajesty



PostPosted: Sat Apr 20, 2013 7:35 pm    Post subject: 8 Reply with quote

Programming 101 at my college was taught with PL-C.
Back to top
View user's profile Send private message Send e-mail
Zag
Tired of his old title



PostPosted: Sat Apr 20, 2013 7:49 pm    Post subject: 9 Reply with quote

By the way, I have written a single significant program in Scheme, for a post-grad course I took at MIT while I was working at Lotus. I finished the program at 3:00 am one night, to turn it in the following afternoon. I got up the next morning, thinking of another use case I should try. I tried it and it worked, then I got to wondering how it could possibly have worked. As I looked through the code, there were sections of it I couldn't understand. Note that this was code I had written only 8 hours before.

Admittedly, I had written it in a caffeine-fueled haze of brilliance that was beyond my just-awake self, but I honestly couldn't even follow how it worked. Yay for write-only languages!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Death Mage
Raving Lunatic



PostPosted: Sat Apr 20, 2013 8:22 pm    Post subject: 10 Reply with quote

Ah yes, zone coding is best coding. (Though there are some who assert that being 'in the zone' while coding is detrimental, I tried to engineer situations to make it easier for me to get into the zone to focus on the code, and it always served me well.)
_________________
* These senseless ramblings brought to you by Insanity™. If you just can't figure the dang thing out, it must be Insanity™.
[YOUR AD HERE!]
Back to top
View user's profile Send private message
novice
No harm. Pun intended!



PostPosted: Sat Apr 20, 2013 9:03 pm    Post subject: 11 Reply with quote

extropalopakettle wrote:
I'm also fairly adept at writing Lisp functions backwards (right to left, bottom to top) ... a fun party trick if it's the right crowd (but it seldom is).


I can imagine. Laughing
Back to top
View user's profile Send private message
MNOWAX
0.999... of a Troll



PostPosted: Sat Apr 20, 2013 9:11 pm    Post subject: 12 Reply with quote

http://jackswaggerofmars.tumblr.com/
_________________
The Man The Myth The Legend
MNOWAX
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
LordKinbote
Daedalian Member



PostPosted: Sat Apr 20, 2013 10:14 pm    Post subject: 13 Reply with quote

Zag wrote:
LordKinbote wrote:
Programming 101 at my college was taught with Scheme.

Did you go to MIT? What a terrible, terrible choice for a Programming 101 language.


Vassar. I was sure that they weren't teaching Scheme anymore as a first language, but nope, they still are (I took CS101 in Fall '01).
Back to top
View user's profile Send private message
extropalopakettle
No offense, but....



PostPosted: Sat May 18, 2013 12:27 am    Post subject: 14 Reply with quote

I downloaded and installed a LISP interpreter the other day, just to see how readily I could solve some old tricks, and decided it IS a good first programming language, and that I'm going to teach it to my kids. A good programming language, not so much in terms of practicality, but for other reasons. Not sure how to articulate it, but a favorite simple example is to write a LISP function which takes a list of distinct symbols, and returns a list of all permutations of that list. A simpler precursor to that might be to take the same list, treat it as a set, and return a list of all subsets. The algorithms and their implementations are very simple, but minor details that need to be done right teach a certain attention to detail often lost, because it's not so much needed, in other language. Very often in LISP, there seems to be a single right way to solve a problem that stands out as most aesthetic.

The simplicity of the language itself is also appealing - the fact that one can write a fully functional interpreter for it in a very few lines of code, either in LISP itself, or most other languages.
Back to top
View user's profile Send private message
extropalopakettle
No offense, but....



PostPosted: Sat May 18, 2013 12:33 am    Post subject: 15 Reply with quote

And then I found this:

Back to top
View user's profile Send private message
Zag
Tired of his old title



PostPosted: Sat May 18, 2013 2:17 am    Post subject: 16 Reply with quote

extropalopakettle wrote:
I .. decided it IS a good first programming language, and that I'm going to teach it to my kids. A good programming language, not so much in terms of practicality, but for other reasons. Not sure how to articulate it, but a favorite simple example is to write a LISP function which takes a list of distinct symbols, and returns a list of all permutations of that list.

If you think that understanding recursion is one of the first tasks that one should learn in programming, then I would have to respectfully say that you're nuts.

Basic program flow (i.e. if-then-else, while loops, subroutines), arrays, data structures, encapsulation, all should come before recursion, IMHO. Admittedly, all these things could be learned in a single semester of programming, and then LISP makes a nice second language, but not a first one.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
extropalopakettle
No offense, but....



PostPosted: Sat May 18, 2013 4:24 am    Post subject: 17 Reply with quote

Zag wrote:
If you think that understanding recursion is one of the first tasks that one should learn in programming, then I would have to respectfully say that you're nuts.

Basic program flow (i.e. if-then-else, while loops, subroutines), arrays, data structures, encapsulation, all should come before recursion, IMHO.


Why?

Because they're simpler to understand? I think that's a myth. If you're first taught iterative procedural style programming, then functional programming based on recursion might later seem unnatural, but I think it's simpler and can be taught in such a way as to be very intuitive.

For instance, consider defining a function for the largest element in a list:

If the list contains one element, that element is the largest, otherwise it's the larger of the first element and the largest of the remaining elements. Trivial, and I think simpler than any iterative definition.

Or defining 'ancestors' as one's parents and one's parent's ancestors. What is the equally precise, complete non-recursive definition that nears that in simplicity and transparency? Ifs, whiles, assignments to variables ... and oh, I think we might need a stack or a queue.

Granted, the cpu executes machine language in an iterative, procedural way (i.e. all statements are executed for a side effect). It's good to learn that someday, just as it's good to learn about logic gates, and the properties of silicon as they apply to computers, to be well-rounded about all things computers in the working world.

But LISP is certainly a simpler language, often allowing simpler expressions of solutions. I doubt any language could have a simpler syntax and semantics, and I think it's better to start with what's simple.
Back to top
View user's profile Send private message
extropalopakettle
No offense, but....



PostPosted: Sat May 18, 2013 2:52 pm    Post subject: 18 Reply with quote

Another example, generating all permutations of a list. The recursive algorithm is short and its correctness is obvious. Iterative solutions are longer, more complicated, and far less obvious.

In LISP:
(defun perms (l) (if (null l) '(()) (mapcan (lambda (l2) (insert (car l) l2)) (perms (cdr l)))))

(defun insert (x l) (if (null l) (list (list x)) (cons (cons x l) (mapcar (lambda (l2) (cons (car l) l2)) (insert x (cdr l))))))

From what I see of real world code written by others that I've had to work on over the years, simplicity and obvious correctness of algorithms and implementation aren't appreciated enough.
Back to top
View user's profile Send private message
Trojan Horse
Daedalian Member



PostPosted: Sat May 18, 2013 3:36 pm    Post subject: 19 Reply with quote

I don't know, extro. "Simple" as in short and succinct does not necessarily mean "simple" as in easy to understand. Even if you took someone who had never programmed at all before (and thus, they hadn't already gotten used to iterative programming), I think you'd still struggle to teach them recursion. Why?

People think iteratively.

Let's take your example of defining the term "ancestors". If you asked a random person to define that term, I doubt you would get an answer of "my parents, and my parents' ancestors". The answer would most likely be something like "my parents, and my parents' parents, and my parents' parents' parents, and so on." An iterative definition.

Or take your example of finding the largest element in a list. Just to have a concrete example, let's say the list is (5 8 4 10 6 2 13 3 1). Ask a random person how you would find the largest number of that list, and ask them to break down the process step by step. Which of these explanations do you think you would get?

Explanation A: "The first two numbers are 5 and 8; the larger of those is 8. The next number is 4; that's smaller than 8, so 8 is the biggest so far. The next number is 10; that's bigger than 8, so 10 is the biggest so far. The next..."

Explanation B: "To find the largest of the nine numbers, all I need to do is find the larger of 5 and the largest of the other eight numbers. To find the largest of those other eight numbers, all I need to do is find the larger of 8 and the largest of the other seven numbers. To find the largest of those other seven numbers..."

I think it's obvious. You'd get explanation A. Iterative thinking is much more natural than recursive thinking.

Now, there's something to be said for making a student stand at the deep end of a pool, and pushing him in. It may be a good idea to make the student struggle with recursion from the very beginning. But it will be a struggle.
Back to top
View user's profile Send private message Send e-mail
extropalopakettle
No offense, but....



PostPosted: Sat May 18, 2013 8:30 pm    Post subject: 20 Reply with quote

Trojan Horse wrote:
I don't know, extro. "Simple" as in short and succinct does not necessarily mean "simple" as in easy to understand.


I'm not saying the latter necessarily follows from the former, but yes, good recursive solutions are often much easier to understand than iterative ones.

Trojan Horse wrote:
Let's take your example of defining the term "ancestors". If you asked a random person to define that term, I doubt you would get an answer of "my parents, and my parents' ancestors". The answer would most likely be something like "my parents, and my parents' parents, and my parents' parents' parents, and so on." An iterative definition.


And when teaching how to clearly define something, one must be taught not to use vague phrases like "and so on". How do you formalize "and so on" iteratively to have a complete and precise definition? A random person doesn't care, but a programmer must. The recursive definition is complete.

Trojan Horse wrote:
Or take your example of finding the largest element in a list. Just to have a concrete example, let's say the list is (5 8 4 10 6 2 13 3 1). Ask a random person how you would find the largest number of that list, and ask them to break down the process step by step. Which of these explanations do you think you would get?

Explanation A: "The first two numbers are 5 and 8; the larger of those is 8. The next number is 4; that's smaller than 8, so 8 is the biggest so far. The next number is 10; that's bigger than 8, so 10 is the biggest so far. The next..."

Explanation B: "To find the largest of the nine numbers, all I need to do is find the larger of 5 and the largest of the other eight numbers. To find the largest of those other eight numbers, all I need to do is find the larger of 8 and the largest of the other seven numbers. To find the largest of those other seven numbers..."

I think it's obvious. You'd get explanation A. Iterative thinking is much more natural than recursive thinking.


A random person would say they scanned the list left to right and saw 13 was the largest. They wouldn't go to lower detail. If you were going to teach such a random person to be a programmer, you'd have to teach them what are the basic operations that can be assumed.

BTW, your explanation A fails when there's only one element in the list (common mistake with iterative programming), and is incomplete ("..." being undefined), while explanation B can stop at the first of the three sentences and be seen as complete and correct, though someone indoctrinated in iterative thinking might feel compelled to go redundantly beyond completeness and correctness.

Largest element of list L = first element of L if there's only one element, otherwise the larger of the first element and the largest of the remaining elements.

It's much easier to see the correctness of that ... in fact an inductive proof of it's correctness is obvious ... than it is to see, much less prove, the correctness of an iterative solution:

Let X = the 1st element
Let N =2
While N < number of elements,
. . . if Nth element > X let X = Nth element
. . . Let N = N + 1
Output X

No, random people don't naturally think that way. They have to be taught that.

Try something like permutations of [A B C D]. OK, take the permutations of [B C D]. They are: [B C D],[C B D],[C D B],[B D C],[D B C],[D C B]. Now for each of those six, insert A in every possible position. So for [B C D] there's [A B C D],[B A C D],[B C A D],[B C D A]. Similarly for the other 5. Done. Finito. Complete, and obviously correct.

Find me any iterative solution for that, no matter how simple or complex, that is as easy to understand, or that is as obviously correct.

But the beauty of LISP isn't in recursion. The syntax can be learned completely in minutes. If I were teaching LISP, I would get to recursive functions on numbers and lists within an hour. I could teach sorting a list of numbers within the first hour to a complete programming novice on the first day, while in other languages we'd be bogged down in input, output, syntax of the various control structures and the program as a whole.
Back to top
View user's profile Send private message
esme
^^^^-- is female! Get the pronouns right



PostPosted: Sat May 18, 2013 11:12 pm    Post subject: 21 Reply with quote

extropalopakettle wrote:
Another example, generating all permutations of a list. The recursive algorithm is short and its correctness is obvious. Iterative solutions are longer, more complicated, and far less obvious.
What is the difference between "recursive" and "iterative"?
_________________
Mundus vult decipi, ergo decipiatur.
Back to top
View user's profile Send private message
Elethiomel
Daedalian Member



PostPosted: Sat May 18, 2013 11:30 pm    Post subject: 22 Reply with quote

Iteration is straightforward. Just do one thing after the other.

In order to understand recursion, one must first understand recursion.
Back to top
View user's profile Send private message
Zag
Tired of his old title



PostPosted: Sat May 18, 2013 11:44 pm    Post subject: 23 Reply with quote

esme wrote:
extropalopakettle wrote:
Another example, generating all permutations of a list. The recursive algorithm is short and its correctness is obvious. Iterative solutions are longer, more complicated, and far less obvious.
What is the difference between "recursive" and "iterative"?

That's actually a trickier question that it seems, at first, to people who learn iterative programming first. Most recursive algorithms can be (and are, by smart compilers) re-written to be interative. (They are rewritten because an iterative solution is almost always more efficient.)

Anyway, your question -- sorry, I got distracted.

An iterative solution is usually of the form
Process Y performed on a list is defined as "Do Step X for every element in the list."

A recursive solution for the same problem is of the form
Process Y performed on a list is defined as "Do Step X for the first element of the list and then do Process Y on the rest of the list."

LISP does this so much that they have expressions for "the first element of a list" and "the rest of the list." Of course, for reasons unknown to humankind, they named these expressions "car" and "cdr" respectively. (Those are pronounced like "car" and "could-rr," but with less vowel sound.)

However, sometimes a recursive solution can be summarized as
Process Y performed on a single element is defined as "Do Step X for the element and then do Process Y on each of the element's children." For instance, this problem:

Starting at a particular folder on your hard drive, (say, "c:/Program Files") print out the names of all the files that are within it directly or indirectly.

That process would look like this, more or less. It takes as an argument, text which is the name of a folder or a file. I'm assuming that the Print operation is built into the language (which it is in nearly every higher-level programming language).

Code:

Define Process PrintOutFilenames ( fileName )
{
    Print (fileName)
    if (fileName represents a folder)
    {
        ForEach file immediately inside folder
        PrintOutFilenames (file)
    }
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
extropalopakettle
No offense, but....



PostPosted: Sun May 19, 2013 3:30 am    Post subject: 24 Reply with quote

esme wrote:
extropalopakettle wrote:
Another example, generating all permutations of a list. The recursive algorithm is short and its correctness is obvious. Iterative solutions are longer, more complicated, and far less obvious.
What is the difference between "recursive" and "iterative"?


I think a better distinction is between procedural languages and functional languages. Procedural tends to employ iteration (looping) in many places where functional employs recursion (though there are certainly recursive procedures too)..

The distinction between procedural and functional is:

In procedural languages, programs are sequences of statements which are instructions to do something. These things are done for their side effects, generally making a change to some global state.

In functional languages, programs are expressions which denote values, and in purely functional programming, no statements which produce side effects (such as the assignment statement) are used. In purely functional programming, there are no verbs ... no instructions to do something, only noun phrases ... descriptions of values.

example: Factorial of X

Procedurally, we have statements telling what to do to calculate it:
Let P = 1;
while X>0 do
. . . Let P = P * X
. . . Let X = X - 1;
end while
Write P

Functionally, we have a definition of the value:
The factorial of X is 1 if X is 0, otherwise it's X times the factorial of X-1;
Back to top
View user's profile Send private message
esme
^^^^-- is female! Get the pronouns right



PostPosted: Sun May 19, 2013 8:03 am    Post subject: 25 Reply with quote

Thank you all for your explanations.
_________________
Mundus vult decipi, ergo decipiatur.
Back to top
View user's profile Send private message
extropalopakettle
No offense, but....



PostPosted: Sun May 19, 2013 4:14 pm    Post subject: 26 Reply with quote

http://xkcd.com/244/
Back to top
View user's profile Send private message
LordKinbote
Daedalian Member



PostPosted: Sun May 19, 2013 9:14 pm    Post subject: 27 Reply with quote

esme wrote:
Thank you all for your explanations.


Google is strangely unhelpful in this query.
Back to top
View user's profile Send private message
Display posts from previous: by   
Reply to topic    The Grey Labyrinth Forum Index -> Off-Topic All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Site Design by Wx3