← Back to Reference Manual Index
Core LispBM
Randomref
# LispBM Random Extensions Reference Manual

The random extensions provide functions for seeding and generating pseudo-random numbers. These extensions may or may not be present depending on the platform and configuration of LispBM.

Random Number Generation

seed

seed sets the seed of the random number generator. The form of a seed expression is (seed expr) where expr must evaluate to a number. Returns t.

Example Result
(seed 42)
t
(seed 177739)
t

random

random generates the next pseudo-random number. The form of a random expression is (random). Returns an unsigned integer (type-u). The range of values and the algorithm used are platform-dependent. In the LispBM reference implementation a linear congruential generator is used and values are in the range 0 to 268435182, chosen to fit within the 28-bit value range of type-u on 32-bit platforms.

Example Result
(random)
195031745u
(random)
250962429u
(random)
237040791u
(mod (random) 11)
6u

This document was generated by LispBM version 0.36.0