• duplic8

    From B. Pym@21:1/5 to Erik Naggum on Mon Jul 1 21:48:33 2024
    Erik Naggum wrote:

    I prefer to use KEY and TEST keyword arguments that default to #'IDENTITY
    and #'EQL.

    (defun duplic8 (element list &key (test #'eql) (key #'identity))
    (loop for x in list
    collect x
    when (funcall test (funcall key x) element) collect x))

    Scheme

    (append-map
    (lambda (x) (if (equal? x 'M) (list x x x) (list x)))
    '(i M j l))

    ===>
    (i M M M j l)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)