A TableFunction that will shuffle the Table contents by random would be helpfull.
I´m not 100% sure, maybe this can be reached by using:
Sort(array[, sortfunc])
with a randomizer sortfunc.
Shuffle Table
Re: Shuffle Table
Code: Select all
nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Sort(nums, Function(a, b) Return(Rnd(1)) EndFunction)
For k = 0 To 9
DebugPrint(nums[k])
Next
Re: Shuffle Table
I don't really understand why, but the code Bugala suggested gives the exact same new list every time (so not really random).
This code does seem to work, though:
This code does seem to work, though:
Code: Select all
nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
?Sort(nums, Function(a, b) Return(Rnd(2)) EndFunction)
For k = 0 To 9
error=?DebugPrint(nums[k])
If error<>Nil Then DebugPrint("Error")
Next

 Posts: 241
 Joined: Fri May 15, 2015 5:15 pm
 Location: Ft. Collins, Colorado USA
Re: Shuffle Table
Rnd(1) gives 1 possible integer value of 0
Rnd(2) gives 1 of 2 possible values: 0 or 1. This is due to the range select value being applied as a modulo operation.
Rnd(2) gives 1 of 2 possible values: 0 or 1. This is due to the range select value being applied as a modulo operation.