< Back to IRCAM Forum

Remove an element from a list, randomise new list, repeat till half length is left

remove_randomise_repeat.omp (3.4 KB)
Good morning all,

I have a little recursion question.

I have an even number of elements in a list, and I wish to remove one element randomly. I then want to randomly permute that result. I would then like to repeat that process until half the original string length is left; for example, if 10 elements long, a list of five would be the final output. So, for example:

ABCDEFGHIJ
BDCEGFHID
DIHFEGC
Until
CGHFE

My patch so far is basic (and by repeating this process full of problems as elements keep being scrambled!)

Any suggestions or help much appreciated.

Thank you!

Krhes

Update to previous post - this still doesn’t work but it at least is closer. I know the output should apply nth-random/remove/permut-random to every shortened line but how alludes me remove_randomise_repeat 2.omp (5.4 KB)
Any hints?
Thanks again,
Krhes

Hi krhes,

What you need here is a loop with accum followed by a collect (see below):

And here is the patch:
remove_randomise_repeat 3.omp (6.5 KB)

Best
K

1 Like

Thank you Karim!!

accum!! (damn).

Much appreciated.

Best,
Krhes