RosettaCodeData/Task/Singly-linked-list-Element-.../Common-Lisp/singly-linked-list-element-...

5 lines
202 B
Common Lisp

(defun simple-insert-after (new-element old-element list &key (test 'eql))
(let ((tail (rest (member old-element list :test test))))
(nconc (ldiff list tail)
(cons new-element tail))))