< Back to IRCAM Forum

Combinations without repetition

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

Trios-2.omp (4.43 KB)

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.

trios-2-numerics.omp (7.43 KB)

Hi Anders,

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

Cheers !

Hi,
I am a beginner but I found sub-power (from MathTools) very straighforward for this task, including dealing with symbols. Maybe it could be useful for somebody.
Regards
sub-power-combinations-no-dup.omp (2.4 KB)