University of Washington • CSE583 • D. Notkin © 2000
31
Yet another example
lAppend two lists non-destructively
–Requires a copy of the first list but not the second one
–Sharing of list substructures is common and safe with no side-effects
l(define (append x1 x2)
   (if (null? x1) x2
       (cons (car x1)
             (append (cdr x1)
                     x2))))