shuffle a list to join channels - 30/11/12 01:11 AM
Hello Forum,
Notwithstanding my recent threads in the 'Feature Suggestions' forum, I have a challenge for you.
I would like to join 3 channels in a random order. The trivial solution is to enumerate the possible orders of the list, and pick a random integer 1..6. [untested]
But this is unwieldy, and inconvenient for a list of 4 channels, let alone 5 channels with 120 permutations or 6 with 720.
How do you shuffle a list in MSL?
Notwithstanding my recent threads in the 'Feature Suggestions' forum, I have a challenge for you.
I would like to join 3 channels in a random order. The trivial solution is to enumerate the possible orders of the list, and pick a random integer 1..6. [untested]
Code:
var %rand0 $rand(1,6) if (%rand0 == 1) join A B C elseif (%rand0 == 2) join A C B elseif (%rand0 == 3) join B A C elseif (%rand0 == 4) join B C A elseif (%rand0 == 5) join C A B elseif (%rand0 == 6) join C B A
But this is unwieldy, and inconvenient for a list of 4 channels, let alone 5 channels with 120 permutations or 6 with 720.
How do you shuffle a list in MSL?