Hi,
currently I'm facing the following problem and I would be very glad, if anyone could help:
from the following list ((a b c) (a b c) (a b) (a b) (a) (a)) I want to remove all duplicates, except (a b c). The result should be the list ((a b c) (a b c) (a b) (a)).
As this function should operate on the first list, irrespective of the number of (a b c), (a b) or (a).
I tried the function "remove-duplicates", but I don't know how to adapt it so that (a b c) duplicates are not removed.
For any help I would be very grateful!
And please excuse any errors regarding my English...
remove-duplicates and if
Re: remove-duplicates and if
Your spec is not complete. Why do you want to keep (A B C) only? Do you want to keep the first? Do you want to keep all the (A B C)? Do you want to remove only the duplicates of length other than 3?
Assuming you want to keep all entries of length equal 3, here is a solution that should give you a hint about other cases"
Cheers
--
MA
Assuming you want to keep all entries of length equal 3, here is a solution that should give you a hint about other cases"
Code: Select all
(remove-duplicates '((a b c) (a b c) (a b) (a b) (a) (a))
:test (lambda (x y)
(and (/= (length x) 3)
(/= (length y) 3)
(equal x y))))
--
MA
Marco Antoniotti
Re: remove-duplicates and if
Perfect, that's exactly what I was looking for! Thanks!