Blob


1 (define (test-case actual expected)
2 (newline)
3 (display "Actual: ")
4 (display actual)
5 (newline)
6 (display "Expected: ")
7 (display expected)
8 (newline))
10 (define (append! x y)
11 (set-cdr! (last-pair x) y)
12 x)
14 (define (last-pair x)
15 (if (null? (cdr x))
16 x
17 (last-pair (cdr x))))
19 (define x (list 'a 'b))
20 (define y (list 'c 'd))
21 (define z (append x y))
22 (test-case z '(a b c d))
23 (test-case (cdr x) '(b))
24 (define w (append! x y))
25 (test-case w '(a b c d))
26 (test-case (cdr x) '(b c d))