Blame


1 665c255d 2023-08-04 jrmu (define (test-case actual expected)
2 665c255d 2023-08-04 jrmu (newline)
3 665c255d 2023-08-04 jrmu (display "Actual: ")
4 665c255d 2023-08-04 jrmu (display actual)
5 665c255d 2023-08-04 jrmu (newline)
6 665c255d 2023-08-04 jrmu (display "Expected: ")
7 665c255d 2023-08-04 jrmu (display expected)
8 665c255d 2023-08-04 jrmu (newline))
9 665c255d 2023-08-04 jrmu
10 665c255d 2023-08-04 jrmu (define (append! x y)
11 665c255d 2023-08-04 jrmu (set-cdr! (last-pair x) y)
12 665c255d 2023-08-04 jrmu x)
13 665c255d 2023-08-04 jrmu
14 665c255d 2023-08-04 jrmu (define (last-pair x)
15 665c255d 2023-08-04 jrmu (if (null? (cdr x))
16 665c255d 2023-08-04 jrmu x
17 665c255d 2023-08-04 jrmu (last-pair (cdr x))))
18 665c255d 2023-08-04 jrmu
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))