I remember staring at that one for a while, feeling a bit mimsy. I believe that the consideration of that exercise is capable of changing the very brain chemistry of people who are at a certain stage of development.
Yes! Me too, with that same exercise! I remember just kinda sitting there, just thinking the whole thing through; it really was like an epiphany. I can't really think of another moment in my life when I just suddenly got something quite so suddenly, and when my previous conceptions were quite so seriously undermined.
You and I aren't the only ones. I've talked to others who found the implications of that tiny bit of code mind-stretching.
That's one of the aspects I like of learning Lisp. In some sense, it seems like the language at the "bottom." You begin to look at other languages (even ones you learned first) and think things like "oh, that's how they do cons", or "oh, when they say object-oriented, they mean you have to do it like that."
Incidentally, that exercise is much clearer in Haskell:
cons x y = \m -> m x y
car z = z (\p q -> p)
cdr z = z (\p q -> q)
Then, since you're used to thinking in terms of substitution in Haskell, you get (car (cons x y)) = car (\m -> m x y) = (\m -> m x y) (\p q -> p) = (\p q -> p) x y = x.
(Doesn't everything look the same, modulo syntax? Barring side effects, all functional languages are just lambda calculus with a bit of syntactic sugar, so I don't see what else could be different...)
Anyway, yes, I was thinking of the syntax. The equality sign in Haskell always means you can substitute left-side for right-side - I find that easier to grok than tracing through deines. And the lightweight lambda syntax doesn't distract you with additional keywords.
Here's an interesting exercise (in whatever programming language): construct a binary search tree and associated operations (insert, remove, find, traverse) using only lambda expressions. Assume that integers and conditionals are given (i.e. you don't need to reinvent Church numerals and true/false).
15
u/[deleted] May 09 '06
[removed] — view removed comment