Hi Om Users
I need a function which gives me the duplicates from my list… like remove-dub but to get the duplicates…
for example
(1 2 3 2 4 3 ) -> (2 3)
is there any existing function?
Thanks a lot
Best
Lena
Hi Om Users
I need a function which gives me the duplicates from my list… like remove-dub but to get the duplicates…
for example
(1 2 3 2 4 3 ) -> (2 3)
is there any existing function?
Thanks a lot
Best
Lena
Dear Lena,
Here something from the net. It is a recursive function. Just copy it in a file named xxx.lisp
and put it in the init folder in your OM app.
the code :
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(in-package :om)
(defun list-dups ( l )
(if l
(if (member (car l) (cdr l))
(cons (car l) (list-dups (remove (car l) (cdr l))))
(list-dups (remove (car l) (cdr l)))
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Hope this helps
Best
K
Dear Karim
Sry for late reply… thank you for this nice solution!
It works
Best
L