nconc (a standard function in Common Lisp) is a destructive function that works like append.
> (define lst '(a b c)) lst> (nconc lst '(d e)) (a b c d e)
> lst (a b c d e)
nconc can be implemented as follows:
(define (nconc x y)
(define (nconc2 x y)
(if (pair? (cdr x))
(nconc2 (cdr x) y)
(set-cdr! x y)))
(if (pair? x)
(begin (nconc2 x y) x)
y) )
Contents    Page-10    Prev    Next    Page+10    Index