Re:Lisp in about 200 lines of Ruby
by twilightsentry on Saturday November 14, 2009 @07:32PM
(#942397)
No, not really, unless you're running the code in a metacircular interpreter.
Imagine encoding the pair ('hello . 'world) into a function. You might say:
(lambda (msg)
(if (eq msg 'car) 'hello 'world))
You could get 'hello by applying that function to the 'car symbol, or 'world by applying it to anything else. Wrapping that in another function lets us generalise to any CAR/CDR. (lambda (car-value cdr-value)
(lambda (msg)
(if (eq msg 'car) car-value cdr-value)))
I thought what you wrote was supposed to be a primitive implementation of the functions.