Group Admins

  • Profile picture of Karim
  • Profile picture of Jean

OpenMusic

Public Group active 6 hours, 45 minutes ago

User group for OpenMusic and computer-aided composition. Visit the Forum for discussions.

Remove-dup

Author 3 Subscribed Users |
Profile photo of krhes
krhes

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.

August 11, 2017 at 18:42 #23388
Profile photo of Karim
Karim

Hi krhes

Just use in second input instead of eq
equal

It will remove whatever duplicate.

BEst
K

August 11, 2017 at 18:54 #23389
Profile photo of Jimmie
Jimmie

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

Attachments:
  1. Capture-d’écran-2017-08-11-à-13.51.07

    Capture-d’écran-2017-08-11-à-13.51.07.png

  2. Capture-d’écran-2017-08-11-à-13.51.07

    Capture-d’écran-2017-08-11-à-13.51.07.png

  1. remove-list-dup.omp
  2. remove-list-dup.omp
August 11, 2017 at 19:03 #23390
Profile photo of krhes
krhes

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

August 11, 2017 at 20:33 #23395

You must be logged in to reply to this topic.

Log in now