hello, looking for an easy solution concerning the following issue: i'd like to generate a bunch of numbers, for example 12 in a row using the object (random) for example from 0 to 11 (or another object?). the actual order of the row should be random, the only restriction would be that, after a number appeared, no repetition of that number is allowed until all the other 11 are through... any suggestions? Thanks a lot!
-
generate series of numbers dodecaphonic style
-
there's [urn] in zexy, which seems to do what you want.
edit: for vanilla, here's an abstraction, that should do pretty much the same (i hope... )
v.urn.pd -
@steff Here is another approach using text: It takes a number to the inlet and outputs a random list of numbers of this length.
First a list of numbers is generated and stored in [text], then one by one a number is drawn randomly from that urn, the line is deleted from text and added to a list. In the end the list is sent out.
-
I've heard that the "right" way (with only one operation per output) to do this is to start with an array with values equal to the index. (at 1 =1, at 0 = 0 etc). Then you read a random index, output it, then swap it with the last element of the array. Next time, you choose a random index except for the last, swap it with the second-to-last, and continue decrementing the range of random indices and swapping with the last index that hasn't been swapped yet every time until you reach the beginning of the array.
see c_urn in RjDj for an example in vanilla: https://github.com/rjdj/rjlib/tree/master/rj -
@seb-harmonik.ar Yes, this is basically what @toxonic's and my proposed solutions do