learning-sicp

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

exercise-12.scm (1285B)


      1 (define-library (sicp tests chapter-3 exercise-12)
      2   (import (scheme base)
      3           (srfi :64)
      4           (only (sicp solutions chapter-3 exercise-12) append!))
      5 
      6   (begin
      7     (define x (list 'a 'b))
      8     (define y (list 'c 'd))
      9     (define z (append x y))
     10 
     11     ;; x: ['a | -]-> ['b | '()]
     12     ;; y: ['c | -]-> ['d | '()]
     13     ;;        ^
     14     ;;        |
     15     ;;        +----------------+
     16     ;;                         |
     17     ;; z: ['a | -]-> ['b | -]--+
     18 
     19     (test-begin "chapter-3-exercise-12")
     20     (test-equal
     21         '(a b c d)
     22       z)
     23     (test-equal
     24         '(b)
     25       (cdr x))
     26     (define w (append! x y))
     27 
     28     ;;        +-------------------+
     29     ;;        |                   |
     30     ;;        v                   |
     31     ;; x: ['a | -]-> ['b | -]--+  |
     32     ;;                         |  |
     33     ;;        +----------------+  |
     34     ;;        |                   |
     35     ;;        V                   |
     36     ;; y: ['c | -]-> ['d | '()]   |
     37     ;;        ^                   |
     38     ;;        |                   |
     39     ;;        +----------------+  |
     40     ;;                         |  |
     41     ;; z: ['a | -]-> ['b | -]--+  |
     42     ;; w: ------------------------+
     43 
     44     (test-equal
     45         '(a b c d)
     46       w)
     47     (test-equal
     48         '(b c d)
     49       (cdr x))
     50     (test-end "chapter-3-exercise-12")))