RosettaCodeData/Task/Singly-linked-list-Element-insertion/Common-Lisp/singly-linked-list-element-insertion-2.lisp
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

4 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))))