News for hackers. Stuff that matters.
Re:Lisp in about 200 lines of Ruby by mquander on Monday November 09, 2009 @10:05AM (#930990)
Those look correct to me. The function returned by cons is just a switch that holds two values in a closure, and interprets what you pass it as a signal to determine which to retrieve. You could just as easily rewrite it to pass it 0 or 1 instead of car and cdr.

If you evaluate (car (cons 1 2)) and (cdr (cons 1 2)) on paper using substitution, you'll see how it works.

Re:Lisp in about 200 lines of Ruby by dkersten on Monday November 09, 2009 @11:46AM (#931217)
Exactly. SICP shows some similar code, though I don't remember which part..