August 19, 2024

P14 - Duplicate the elements of a list

Example:* (dupli '(a b c c d))(A A B B C C C C D D)

lisp

(defun dupli (lista)
    (if (eql lista nil)
        nil
    (append (list (car lista) (car lista)) ( dupli (cdr lista)))
    )
)

(dupli '(1 2 3 4 5 6 7 8))
Be first to comment
Leave a reply