quickutil icon indicating copy to clipboard operation
quickutil copied to clipboard

EXTEND-LIST: Mutatively construct a list in forward order.

Open heegaiximephoomeeghahyaiseekh opened this issue 8 years ago • 0 comments

;; 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