An implementation of cons, car, and cdr

We can build rational numbers and line segments and vectors and all of this stuff in terms of pairs ... out of nothing at all--pure abstraction.

- Hal Abelson, SICP video lecture 2b


(define (cons a b)
(lambda (pick)
(cond ((= pick 1) a)
((= pick 2) b))))
(define (car x) (x 1))
(define (cdr x) (x 2))

Practical? Who cares! Learning stuff like this is an antidote to this:
  1. Create table
  2. Create DAO
  3. Create View
  4. Create template
  5. Sync changes
  6. Deploy
I'm enjoying the heck out of reading SICP slowly, working through the exercises, and watching the videos.

Posted in Labels: , |

0 comments: