View Single Post
  #1 (permalink)  
Old 06-30-2007, 04:24 PM
Stellaferox Stellaferox is offline
Basic4ppc Veteran
 
Join Date: Apr 2007
Posts: 269
Default how to random shuffle an array?

Hi,

I need to shuffle an array with numbers in a random way, let's say cardnumbers (in fact something else that has to do with neural networks but the same procedure).
Now I think this has to be a loop, run at least once in which the condition has to be that the array already holds the number in which case a new randomnumber is set, looping unitl this number is not yet in the array.
Like:

FOR c = Nr1 to Nr2+1
DO
x = RND(Nr1,NR2)
UNTIL (x NOT in ArrayOfNumbers())
ArrayOfNumbers(c) = x
NEXT

Or does anyone have a better solution?
tnx
Marc
Reply With Quote