Contents    Page-10    Prev    Next    Page+10    Index   

Append

append concatenates two lists to form a single list. The first argument is copied; the second argument is reused (shared).


(append '(a b c) '(d e))    ->  (a b c d e)


public static Cons append (Cons x, Cons y) {
  if (x == null)
     return y;
   else return cons(first(x),
                    append(rest(x), y)); }


(defun append (x y)
  (if (null x)
      y
      (cons (first x)
            (append (rest x) y)) ) )

This version of append append is simple and elegant, but it takes O(nx) stack space.