< Back to IRCAM Forum

Omloop permutations + comparing lists

Hello everyone,
I do have a noob question…

let’s say I’ve got a list: (0 1 2 3 4 5 6 7 8 9)
I’d like to permut it as follow : (6 5 7 4 8 3 9 2 0 1) then permut the new list etc… and stop when the last list is equal to the first (so I made a hole cycle)

It should be something with “while” in the omloop, but I can’t figure out how to put it

Here is a patch to explain my problem

Also I’m not sure how to compare 2 lists…

Thanks in advance

permutations.omp (11.2 KB)

Sorry, so to compare 2 lists it’s super simple, we just need to use the “equal” list function… sorry for that

But still when I try to use the omwhile it doesn’t work

I don’t know what’s wrong

permutations1.omp (5.37 KB)

Hi Jonathan

You are not very far: a possible solution is shown in the screenshot attached (“V1”).

In this loop:

  • ACCUM acts as a memory and allows you to permut each time the result of the last iteration (you got that part already).
  • COLLECT collects your successive permutations (eachtime) and returns them all at the end of the loop (finally)
  • WHILELOOP tests at the beginning of each iteration if the permutation (POSN-MATCH) of the last permutation (= 2nd output of ACCUM) EQUALS the input list.

An alternative (image “V2”) would be to directly test equality of the last element in COLLECT (using LAST-ELEM) and the INPUT in the WHILELOOP. In this case you would avoid one call to POSN-MATCH but get the original list in the result.

V1.png

Hi Jacob,

I did it using an updating variable. I would be curious to know if there is another way to do this. I will think about it a bit more.
Look at the screenshot: you need to create a global variable or use a store object with slots. the set slot that starts the sequence could be bypassed if you have an init object within the loop. Problem is that init does not work anymore (I still haven’t installed the bug fix that Jean sent me :frowning:
Let me know if this works for you,

Michele

Screen-Shot-2014-09-15-at-9.12.25-AM.tiff (2.83 MB)

It works!!!
Thank you so much,

J