learning-sicp

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

exercise-25.scm (854B)


      1 ;; Exercise 2.25
      2 
      3 (test-begin "2.25")
      4 (test-equal
      5     7
      6   (car (cdr (car (cdr (cdr '(1 3 (5 7) 9)))))))
      7 (test-equal
      8     7
      9   (car (car '((7)))))
     10 (test-equal
     11     7
     12   (car            ;; 7
     13    (cdr           ;; (cons 7 '())
     14     (car          ;; (cons 2 (cons (cons 3 ...) '()))
     15      (cdr         ;; (cons (cons 6 (cons 7 '())) '())
     16       (car        ;; (cons 5 (cons (cons 6 (cons 7 '()) '())))
     17        (cdr       ;; (cons (cons 5 ...) '())
     18         (car      ;; (cons 4 (cons (cons 5 ...) '()))
     19          (cdr     ;; (cons (cons 4 ...) '())
     20           (car    ;; (cons 3 (cons (cons 4 ...) '()))
     21            (cdr   ;; (cons (cons 3 ...) '())
     22             (car  ;; (cons 2 (cons (cons 3 ...) '()))
     23              (cdr ;; (cons (cons 2 ...) '())
     24               ;; (cons 1 (cons (cons 2 ...) '()))
     25               '(1 (2 (3 (4 (5 (6 7)))))))))))))))))))
     26 (test-end "2.25")