Implementation of append

append makes a copy of its first argument lists, but reuses the last list. This is called structure sharing; it causes no problems unless destructive operations are used.

The original lists are unchanged.

(define x '(a b c))
(define y '(d e))
(define z (append x y))
: x 
(a b c)
: y
(d e)
: z
(a b c d e)

(define (append1 x y)
  (if (pair? x)
      (cons (car x)
            (append1 (cdr x) y))
      y) )

Contents    Page-10    Prev    Next    Page+10    Index