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

5 lines
202 B
Common Lisp
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
(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))))