Generates a random number.
(rand a) is equivalent to (rand 0 a).
(rand a b) generates a random number between a and b:
-
If both arguments are integers, then
ais an inclusive bound andbis an exclusive bound, and the result will be an integer. -
If either argument is a float, then both bounds are inclusive and the result will be a float.
There is no requirement for b to be greater than a. For example, (rand -3) may
return 0, -1 or -2; and (rand 5 3) may return 5 or 4.
The built-in random number generator uses a simple linear-congruential algorithm. It may not be appropriate when high-quality randomness is required.