4 ms·
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 det
by mquander 17y ago
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.
- dkersten 17y agoExactly. SICP shows some similar code, though I don't remember which part..