package fmlib_browser

  1. Overview
  2. Docs

Module Fmlib_browser.RandomSource

Generate Random Numbers

Sourcetype 'a t

Generator, generating random values of type 'a.

Sourceval constant : 'a -> 'a t

constant a Generate the same value every time.

Sourceval (>>=) : 'a t -> ('a -> 'b t) -> 'b t

rand >>= f Generate the random value a using the generator rand, and then use f a to generate a random value b.

Sourceval (let*) : 'a t -> ('a -> 'b t) -> 'b t

let* a = rand in f a is the same as rand >>= f.

Sourceval map : ('a -> 'b) -> 'a t -> 'b t

map f rand Use rand to generate a random value and then map it by f.

Sourceval int : int -> int t

int bound A random generator which generates numbers n satisfying 0 <= n < bound.

Precondition: 0 < bound

Sourceval float : float -> float t

float bound A random generator which generates numbers n satisfying 0.0 <= n <= bound.

Precondition: 0 <= bound

Sourceval bool : bool t

Generate a random boolean value.

Sourceval choose : 'a list -> 'a t

uniform lst Generate a random value of the list lst.

Precondition: List must not be empty lst <> []

OCaml

Innovation. Community. Security.