Subject: Re: Novice question -- inserting element in list
From: Erik Naggum <>
Date: 1996/02/06
Newsgroups: comp.lang.lisp
Message-ID: <>

[Gregory Santos]

|   I would simply like to insert an element into the central portion of a
|   list (not the beginning or end) with the highest degree of efficiency
|   possible, knowing only the node after or before which I wish to insert
|   the new node.

(defun insert-after (newelt list index)
  "Insert NEWELT in LIST after the INDEXth cell.
Returns LIST."
  (let ((cell (nthcdr index list)))
    (setf (cdr cell) (cons newelt (cdr cell))))

#<Erik 3032612850517114>
BEOL and ENDOL: the ultimate general purpose programming languages