Library for pseudo-random number generation in Curry.
This library provides operations for generating pseudo-random number sequences. For any given seed, the sequences generated by the operations in this module should be identical to the sequnces generated by the java.util.Random package.
The algorithm is a linear congruential pseudo-random number generator
described in Donald E. Knuth, The
Art of Computer Programming, Volume 2: Seminumerical
Algorithms, section 3.2.1.
Author: Sergio Antoy (with extensions by Michael Hanus)
Version: December 2004
| Exported names: |
Functions:
getRandomSeed
| nextBoolean
| nextInt
| nextIntRange
| Summary of exported functions: |
|
||
|
||
|
||
|
| Imported modules: |
| Exported datatypes: |
| Exported functions: |
:: Int -> [Int]
Returns a sequence of pseudorandom, uniformly distributed 32-bits
integer values. All 232
possible integer values are produced with
(approximately) equal probability.
Example call: (nextInt seed)
seed
- The seed of the random sequence.
:: Int -> Int -> [Int]
Returns a pseudorandom, uniformly distributed sequence of values between 0 (inclusive) and the specified value (exclusive). Each value is a 32-bits positive integer. All n possible values are produced with (approximately) equal probability.
Example call: (nextIntRange seed n)
seed
- The seed of the random sequence.
n
- The bound on the random number to be returned.
Must be positive.
:: Int -> [Bool]
Returns a pseudorandom, uniformly distributed sequence of
boolean values. The
values True and False are produced with
(approximately) equal probability.
Example call: (nextBoolean seed)
seed
- The seed of the random sequence.
:: IO Int
Returns a time-dependent integer number as a seed for really random numbers. Should only be used as a seed for pseudorandom number sequence and not as a random number since the precision is limited to milliseconds