Group Admins

  • Profile picture of Karim
  • Profile picture of Jean


Public Group active 3 days, 20 hours ago

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

Combinations without repetition

Author 2 Subscribed Users |
Profile photo of paddys

I’m trying to build a quite easy patch which can give me all possibilities of duos, trios, quatuors, inside a given ensemble.

I used combinations from OM-Combine and got all possibilities, including repetitions (like 4 violins together when there’s only one in the ensemble). Using an Om-Loop I could filter out the combinations using twice or more the same instrument.

Now my problem is that i get some possibilities more than once because they come in a different order (like sax-piano and piano-sax). So I’m wondering how it is possible to filter out these redundancies. That would mean, filter out repetitions regardless of the order, just looking at the content of the sublists. My patch is joined to this message.

Thanks a lot and kind regards

February 23, 2018 at 13:00 #25666
Profile photo of anders

Hi Paddy.

…filter out repetitions regardless of the order, just looking at the content of the sublists.

Manipulating symbols (ie: cl sax) isn’t straightforward. I think i would convert these to numbers, to be used as indices in a list of instruments after you’ve done your permutation, or perhaps strings.

In your check for duplicates you need to check sorted sublists, which would get rid of similar sets just differing in order. Ie (for numeric sets):

(remove-duplicates myset :test #'(lambda (a b) (equalp (sort a #'<) (sort b #'<))))

Check attached patch as well.

February 23, 2018 at 15:43 #25670
Profile photo of paddys

Hi Anders,

Thanks a lot. Yeah turning it to numeric makes it way easier. This is just what I needed.

Cheers !

February 23, 2018 at 15:55 #25673

You must be logged in to reply to this topic.

Log in now