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