Definition: | set_rand(integer i1) |
Description: | Set the random number generator to a certain state, i1, so that you will get a known series of random numbers on subsequent calls to rand(). |
Comments: | Normally the numbers returned by the rand() function are totally
unpredictable, and will be different each time you run your
program. Sometimes however you may wish to be given the same
series of numbers, for instance when debugging a program.
Note that if more that one thread invokes the rand() function, the results are likely to be unpredictable whether or not the set_rand() function has been called. |
Example: |
sequence s, t s = repeat(0, 3) t = s set_rand(12345) s[1] = rand(10) s[2] = rand(100) s[3] = rand(1000) set_rand(12345) -- same value for set_rand() t[1] = rand(10) -- same arguments to rand() as before t[2] = rand(100) t[3] = rand(1000) -- at this point s and t will be identical |
See Also: | rand |