Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random numbers - the most efficient way
Message
 
 
To
07/09/2004 23:39:16
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00939849
Message ID:
00940338
Views:
38
Al,

That threw me too, but I think you are supposed to use the result of the ? command as the list of randomized cards, not the final array itself.

>I'm not sure this routine is reliable in the general case. For example, it should work if, say, RAND() always returned 0.5. If I modify it as follows (using only 5 cards for illustration):
DIMENSION aCards[5]
>FOR x=1 TO 5
>  aCards[x] = x
>ENDFOR
>RAND(0)
>FOR x=5 TO 1 STEP -1
>  nRnd = INT(0.5*x) + 1
>  nMax = aCards[x]
>  ? aCards[nRnd]
>  aCards[nRnd] = nMax
>ENDFOR
>
>* 5 array values are 1, 4, 4, 4, 5
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform