Commit 83897fa9 authored by Juergen Nickelsen's avatar Juergen Nickelsen
Browse files

made nconc a real nconc and lots faster

parent 881b14ad
......@@ -509,28 +509,17 @@
(defun prog2 (&rest body)
(cadr body))
(defun nconc (l1 l2)
(if (null l1)
l2
(if (null (cdr l1))
(progn (rplacd l1 l2)
l1)
(cons (car l1)
(nconc (cdr l1) l2)))))
(defun nconc (&rest lists)
"concatenate all LISTS by modifying the last cons and return the result"
(while (and lists (null (car lists)))
(pop lists))
(if (null lists)
nil
(let ((l1 (car lists)))
(if (null l1)
(apply #'nconc (cdr lists))
(if (null (cdr l1))
(progn (rplacd l1 (apply #'nconc (cdr lists)))
l1)
(cons (car l1)
(apply #'nconc (cons (cdr l1)
(cdr lists)))))))))
(let* ((result (car lists))
(l result))
(while (cdr l)
(setq l (cdr l)))
(rplacd l (apply #'nconc (cdr lists)))
result)))
(defun append (l1 l2)
(if (null l1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment