[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing Destructive Functions

Here is a function that has the requested behaviour:

(defun replace-first (l new)
  (setf (cdr l) (cons (car l) (cdr l))
        (car l) new))

That is, you add a cons cell after the first one, move the first element to
the second place, and add the new elemnt in its place.
This may not work if you share other parts of the list too.