CS152
Chris Pollett
Apr. 8, 2009
(let ((a 2) (b 3)) (+ a b)) ; evaluates to 5
(begin l1 l2 l3 ...)
((lambda () l1 l2 l3 ...) )
(car '(1 2 3)) ; returns 1 - the head of the list (cdr '(1 2 3)) ; returns (2 3) the tail of the list (cons 0 '(1 2 3)) ; adds to the front of the list (0 1 2 3 4)
(define (my-reverse-list L) (if (null? L) '() (append (my-reverse-list (cdr L)) (list (car L)))))
(define (reverse-aux L list-so-far) (if (null? L) list-so-far (reverse-aux (cdr L) (cons (car L) list-so-far)))) ; tail-recursive (define (my-reverse L) (reverse-aux L '()))