[Closed] Using ArrayCount in parrameters?
Hi all,
Just wondering is it possible to use an array count to a random function.
E.G
MyArray =#(A,B,C,D)
Random 1 MyArray.cont
Basically I want to random between 1 and 4 but using the count to feed the random its parramater. Is this possible?
Thanks
you just misspelt “count”.
MyArray =#(A,B,C,D)
val = Random 1 MyArray.count
Yup. Here is the one of many ways
MyArray =#("A","B","C","D")
fn randomizeArray arr seeding: =
(
newarr = #()
seed seeding
while newarr.count != arr.count do appendIfunique newarr arr[random 1 arr.count]
newarr
)
randomizeArray MyArray seeding:0
or this one
MyArray =#("A","B","C","D")
fn randomizeArray arr seeding: =
(
newarr = #()
seed seeding
while newarr.count != arr.count do
if finditem newarr (item = arr[random 1 arr.count]) == 0 do append newarr item
newarr
)
randomizeArray MyArray seeding:0
try to apply these methods to long arrays (100,000+). they both are endless. because they are wrong
Here we go again:) My head still hurts from “group” thread.
Can we start discussion (6 pages min)?
i remember this tool… it was very slow which means it was using bad randomization functions too
Whoops, sorry about the typo!
Wow thanks, that is a big help, also interesting to see the other ways to randomise, very helpful!
Thank you very much!
Shan
we don’t have to… there is the answer in mini-challenge #1 thread on this forum
this was a min-challenge #1 http://forums.cgsociety.org/showthread.php?f=98&t=980432&highlight=shuffle