quickutil
quickutil copied to clipboard
EXTEND-LIST: Mutatively construct a list in forward order.
;; Write the code here.
(defmacro extend-list (new-value list last-tail)
"Builds a list in the forward direction. LIST and LAST-TAIL must be
SETFable places, and should both be initialized to NIL."
`(progn
(cond (,list
(rplacd ,last-tail (cons ,new-value nil))
(setf ,last-tail (cdr ,last-tail)))
(t
(setf ,list (list ,new-value))
(setf ,last-tail ,list)))
,list))
Provides: EXTEND-LIST Requires: Author: Jeremy Phelps License: Public Domain