ESC
No recent searches
Search by
Standard Library  /  Random

Random

Pseudo-random number generation.

Edit on GitHub
Added in 0.5.0 No other changes yet.
from "random" include Random

Types

Type declarations included in the Random module.

Random.Random

type Random

Values

Functions and constants included in the Random module.

Random.make

Added in 0.5.0 No other changes yet.
make : (seed: Uint64) => Random

Creates a new pseudo-random number generator with the given seed.

Parameters:

seed: The seed for the pseudo-random number generator

Returns:

Random: The pseudo-random number generator

Random.makeUnseeded

Added in 0.5.0 No other changes yet.
makeUnseeded : () => Result<Random, Exception>

Creates a new pseudo-random number generator with a random seed.

Returns:

Result<Random, Exception>: Ok(generator) of a pseudo-random number generator if successful or Err(exception) otherwise

Random.nextUint32

Added in 0.6.0
versionchanges
0.5.0Originally named `nextInt32`
nextUint32 : (random: Random) => Uint32

Generates a random 32-bit integer from the given pseudo-random number generator.

Parameters:

random: The pseudo-random number generator to use

Returns:

Uint32: The randomly generated number

Random.nextUint64

Added in 0.6.0
versionchanges
0.5.0Originally named `nextInt64`
nextUint64 : (random: Random) => Uint64

Generates a random 64-bit integer from the given pseudo-random number generator.

Parameters:

random: The pseudo-random number generator to use

Returns:

Uint64: The randomly generated number

Random.nextUint32InRange

Added in 0.6.0
versionchanges
0.5.0Originally named `nextInt32InRange`
nextUint32InRange : (random: Random, low: Uint32, high: Uint32) => Uint32

Generates a random 32-bit integer from the given pseudo-random number generator from a uniform distribution in the given range.

Parameters:

random: The pseudo-random number generator to use
low: The lower bound of the range (inclusive)
high: The upper bound of the range (exclusive)

Returns:

Uint32: The randomly generated number

Random.nextUint64InRange

Added in 0.6.0
versionchanges
0.5.0Originally named `nextInt64InRange`
nextUint64InRange : (random: Random, low: Uint64, high: Uint64) => Uint64

Generates a random 64-bit integer from the given pseudo-random number generator from a uniform distribution in the given range.

Parameters:

random: The pseudo-random number generator to use
low: The lower bound of the range (inclusive)
high: The upper bound of the range (exclusive)

Returns:

Uint64: The randomly generated number

Sign up for farm-to-inbox developer news

You can unsubscribe at any time. Read our privacy policy.

Copyright © 2024 The Grain Programming Language