< Back to IRCAM Forum

Random selection from a list patch

Currently this patch selects random chunks of A in any order. Ideally I’d like also like to be able to select chunks maintaining the original order and possibly across larger version (for example by reversing the shape and appending to a palindrom version at C).
As an integer example, I’d like something like the following :
(eg. original list is 1 2 3 4 5 6 7 8 9 10 - but could be longer by adding a reverse versionRandom selection from a list patch.omp (14.8 KB)
):
1 2 3
1 2 3 4 5
2 3
5 6 7 8
etc
Can you help?
Thanks as always,
Krhes

Sorry krhes,

If i understand you well you need a reversed version appended to your random output??
If this is the case here is a solution:

The patch:
random selection from a list patch1.omp (17.3 KB)

If it isn’t, please can you be clearer on what you want to do?

Best
K

Thank you Karim, this is helpful as always, and in keeping with my general approach. However, I’d like to keep the output from repeat-n in the order of the original lmidic in the chord-seq. So, if the order of pitches is ((7200) (7200) (7200) (7300 7100 7200) (7100 7400 7000 7200) (7100 7500 7600 6900 7200) (7000 7300 7700 7800 6700 7200) (6900 8000 8100 6500 7300) (6800 8300 8500 6200 7300) (6700 7400 8800 9000 5800 7300)), length being 9, then I would like to randomly select parts of this list but always in order (not randomised). So for example, the first evaluation of random might generate
(7200) (7300 7100 7200) (7100 7400 7000 7200), then the next might give me (7000 7300 7700 7800 6700 7200) (6900 8000 8100 6500 7300) (6800 8300 8500 6200 7300) or (7100 7400 7000 7200) (7100 7500 7600 6900 7200) (7000 7300 7700 7800 6700 7200) (6900 8000 8100 6500 7300), from any starting point in the list (however long if I increase the list length) but wouldn’t randomise the order in which they occur, which is what happens now. I was thinking about using sort. , but that won’t read chords but real numbers. I hope I’m making myself clear. Let me know if not!
Thanks as always for any light you can shed on this,
Krhes

Ok, now i see!
What you want is a ordered “slice” of the list. So you need to forget about posn-match. The trick then is to use nthcdr which gieves nth rest of the list. if the first argument is 0, then you will have all the list. Afterthat you will need another one to slice the result from the end:


Here is the patch:
random selection from a list patch1 2.omp (7.4 KB)
Hope this is it?

Best
K

Dear Karim,
It may not seem much to you but It’s impressive to me! Thank you!! One last thing - is it possible to have each slice be a minimum of three ie 1 chord should not pass?

Best wishes,
Krhes

yes of course, here:


random selection from a list patch1 3.omp (8.7 KB)

Best
K

Karim,

PERFECT! Just what I was looking for. What’s great about this, for me,.is the flexibility of list length whatever the given length of the lmidic list.
Thank you again,
Krhes

No problem, my pleasure.
Best
Good composing!
K

1 Like