< Back to IRCAM Forum

Permutational Combination of 2 Lists

I think this is quite a straightforward problem to solve, but I’ve been trying to solve it for a stupidly long time. I have two lists which I want to combine in the following way;

List 1: (a b c)
List 2: (1 2 3)
Output: (a 1) (a 2) (a 3) (b 1) (b 2) (b 3) (c 1) (c 2) (c 3)

I feel like I’ve come close to cracking it in a few different ways (I’ve tried OMLOOP, MAT-TRANS, POSN-MATCH, MAPCAR to name a few) but haven’t quite got the result.

Multiple solutions would be incredibly useful to see as I’m sure there are a few simple ways to do this which I’m not seeing!

Thanks in advance

Hi hbell25,

A way to do so is like so:

We can do other variations of this of course.

The patch:
patchlist.omp (4.0 KB)

Best
K

1 Like

Thanks Karim, I’d added an extra listloop under the right-hand input which was the problem!

Hi @hbell25,

Thank you for the nice little problem to work on. As I too learn OM I am enjoying seeing the ways that problems can be solved. Of course, @haddad has a much more elegant solution and I would recommend the loop (which I eventually decided on) but I came up with this version that gives the same result.

I have found it helpful to deconstruct loop functions (if possible) and see how their iteration processes work. It really has helped in being able to follow their sometimes hidden flow that leads to a solution.

:slight_smile:

list interlace.omp (7.8 KB)