Copying a List |
![]() ![]() ![]() |
(define (copy-list-1 l) (cond ((null? l) '()) ((pair? l) (cons (copy-list-1 (car l)) (copy-list-1 (cdr l)))) (else l))) (define x '(a b c)) (define y (cons x x)) y ; ((a b c) a b c) (eq? (car y) (cdr y)) ; #T (define z (copy-list-1 y)) z ; ((a b c) a b c) (eq? (car z) (cdr z)) ; #F
Jim Miller | ![]() |