Monday, 26 November 2018

How do you specify a range of random numbers?

The Common Lisp function RANDOM takes two arguments: a limit and a random state. The first argument tells to the function that the generated random number could be one in the range of 0 <= n < limit, for example:

CL-USER> (random 1000)


CL-USER> (random 1.0)

from these examples we clearly understand that limit could be an integer or float number. The second parameter passed to RANDOM is the random state, according to hyperspec is an object which holds informations used by the random number generator inside the computer which are different from implementation to implementation.

No comments:

Post a Comment