learning-sicp

My embarrassing half assed SICP run.
git clone https://kaka.farm/~git/learning-sicp
Log | Files | Refs

exercise-27.scm (477B)


      1 ;; Exercise 2.27
      2 
      3 (letrec ([deep-reverse
      4           (lambda (xs)
      5             (cond
      6              ((null? xs) '())
      7              ((pair? xs)
      8               (append (deep-reverse (cdr xs))
      9                       (list (deep-reverse (car xs)))))
     10              (else xs)))]
     11          [x (list (list 1 2)
     12                   (list 3 4))])
     13   (test-begin "2.27")
     14   (test-equal
     15       '((3 4) (1 2))
     16     (reverse x))
     17   (test-equal
     18       '((4 3) (2 1))
     19     (deep-reverse x))
     20   (test-end "2.27"))