< Back to IRCAM Forum

Remove-dup

Greetings All,

Im interested in the function remove-dup. As I understand this function only works for duplicates in simple lists such as (a b b c d). Is it possible to remove duplicate elements from a list with nested lists (sublists) inside it? To be clear:

Example: A nested lists as follows:
((0 1) (0 2) (0 1) (0 3))

should have one of the repeated (0 1) sublists removed, resulting in:

((0 1) (0 2) (0 3))

Perhaps this is a simple task. If so, apologies! Any suggestions would be gladly received.

Thanks in advance,
Krhes.

Hi krhes

Just use in second input instead of eq
equal

It will remove whatever duplicate.

BEst
K

Hi,

I have this little patch that I have created to do something like what you ask. It could surely be more simple, but I wanted to make it versatile in the following way: as you can see on the image, you can indicate a ‘level’ for removing duplicates, either at all levels (remove dup of lists AND of atoms within each list - this is ‘level0’), or only at the level of lists (level1). I think it is currently made to work only with lists of the format you submitted, I have not tried anything else.

edit: just saw Karim’s reply (using ‘equal’ instead of ‘eq’) - good to know! Well, this corresponds to my ‘level1’ above, so I leave my patch here anyway as a ready-made ‘all-level-remove-dup’, if it can be of any use…

Jimmie

Karim and Jimmie,

Thanks for both your solutions! Simple or more involved, they are both useful!!

As Carl Sagan said:

“There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand the world. There is no such thing as a dumb question.”

Or in my case, to understand OM!

Best,
Krhes