The random function can work on any value of a simple type to return a random value of that type, for example:
random 100 ;== 71random 2.71 ;== 2.027808184808962random "house" ;== "hsuoe"random 2018-02-13 ;== 23-Mar-1968
This command also has a few refinements:
- To pick a random value from a series, use /only:
random/only ["one" "two" "three" "four"] ;== "three"
- /seed restarts the random generator to obtain new random values between runs of the same code; the current time is a good seed. The following code uses this and then prints nine random numbers in a loop:
random/seed now/time loop 9 [ r: random 10 prin r prin space ] ;1st run: == 4 5 3 5 7 9 3 10 10 ;2nd run: == 10 8 10 2 3 1 4 2 1