Nconc

nconc concatenates two lists to form a single list; instead of copying the first list as append does, nconc modifies the end of the first list to point to the second list.


(nconc (list 'a 'b 'c) '(d e))   ->  (a b c d e)


(defun nconc (x y)
  (let (ptr)
    (setq ptr x)
    (if (null x)
        y
        (progn           ; progn is like {  }
          (while (not (null (rest x)))
             (setq x (rest x)) )
          (setf (rest x) y)
          ptr) ) ))


public static Cons nconc (Cons x, Cons y) {
  Cons ptr = x;
  if (x == null)
     return y;
   else { while (rest(x) != null)
            x = rest(x);
          setrest(x, y);
          return ptr; } }

Contents    Page-10    Prev    Next    Page+10    Index