<< Previous exercise (3.11) | Index | Next exercise (3.13) >>

meteorgan

z => (a b c d) (cdr x) => (b) w => (a b c d) (cdr x) => (b c d)

rogerxman

z => (a b c d) (cdr x) => (b c d) w => (a b c d) (cdr x) => (b c d) (define (append x y) (if (null? x) y (cons (car x) (append (cdr x) y)))) (define (append! x y) (define (last-pair x) (if (null? (cdr x)) x (last-pair (cdr x)))) (set-cdr! (last-pair x) y) x) (define x (list 'a 'b)) (define y (list 'c 'd)) (define z (append x y)) (define w (append! x y)) ;test it by yourself. ;thank you.

uuu

do the first (cdr x) before (define w (append! x y)) test it carefully, thank you.

rogerxman

uuu

do the first (cdr x)

before(define w (append! x y))test it carefully, thank you.