about summary refs log blame commit diff stats
path: root/js/games/nluqo.github.io/~bh/61a-pages/Lectures/2.1/cons.scm
blob: 300027e7a91dfc669db045e0434aedec6a2a4c33 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                        
; implementation of pairs as functions

(define (cons x y)
  (lambda (which)
    (cond ((equal? which 'car) x)
	  ((equal? which 'cdr) y)
	  (else (error "Bad message to CONS" which)) )))


(define (car pair)
  (pair 'car))

(define (cdr pair)
  (pair 'cdr))