Debian Codegraph @

doc/guide/src/MLtonRandom.adoc

raw
1 = MLtonRandom
2
3 [source,sml]
4 ----
5 signature MLTON_RANDOM =
6 sig
7 val alphaNumChar: unit -> char
8 val alphaNumString: int -> string
9 val rand: unit -> word
10 val seed: unit -> word option
11 val srand: word -> unit
12 val useed: unit -> word option
13 end
14 ----
15
16 * `alphaNumChar ()`
17 +
18 returns a random alphanumeric character.
19
20 * `alphaNumString n`
21 +
22 returns a string of length `n` of random alphanumeric characters.
23
24 * `rand ()`
25 +
26 returns the next pseudo-random number.
27
28 * `seed ()`
29 +
30 returns a random word from `/dev/random`. Useful as an arg to
31 `srand`. If `/dev/random` can not be read from, `seed ()` returns
32 `NONE`. A call to `seed` may block until enough random bits are
33 available.
34
35 * `srand w`
36 +
37 sets the seed used by `rand` to `w`.
38
39 * `useed ()`
40 +
41 returns a random word from `/dev/urandom`. Useful as an arg to
42 `srand`. If `/dev/urandom` can not be read from, `useed ()` returns
43 `NONE`. A call to `useed` will never block -- it will instead return
44 lower quality random bits.