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)


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


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

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

Contents    Page-10    Prev    Next    Page+10    Index