Ludwig.Random

This module provides psuedorandom number generation suport for Ludwig.

Module Members

randomRange

(Function)

Generate a random number in the given range (inclusive).

Examples:

n: randomRange(1, 100, seedInt(42))

Type Signature

 fun (Int, Int, RandomGen) -> (Int, RandomGen)
Argument: lower

The lower bound of the range (inclusive).

Type: Int

Argument: upper

The upper bound of the range (inclusive).

Type: Int

Argument: generator

The random number generator.

Type: RandomGen

Returns:

A pseudorandom number and a new random number generator.

Type: ( Int, RandomGen)

seedInt

(Function)

Create a new RandomGen from an Ludwig.Int.

Examples:

gen: seedInt(42)

Type Signature

 fun (Int) -> RandomGen
Argument: i

The int to use as the seed.

Type: Int

Returns:

A random generator.

Type: RandomGen

seedString

(Function)

Create a new RandomGen from a Ludwig.String.

Examples:

gen: seedString("test")

Type Signature

 fun (String) -> RandomGen
Argument: s

The string to use as the seed.

Type: String

Returns:

A random generator.

Type: RandomGen

RandomGen

(Type)

type opaque RandomGen

A pseudorandom number generator. These can be constructed using the seedInt or seedString functions.