Initialize the pseudo-random generator with the given seed.

The pseudo-random generator is used by the method rand and other to generate sequence of numbers. These sequences are repeatable by calling srand_from with a same seed value.

srand_from(0)
var a = 10.rand
var b = 100.rand
srand_from(0)
assert 10.rand == a
assert 100.rand == b

Property definitions

core :: math $ Sys :: srand_from
# Initialize the pseudo-random generator with the given seed.
# The pseudo-random generator is used by the method `rand` and other to generate sequence of numbers.
# These sequences are repeatable by calling `srand_from` with a same seed value.
#
# ~~~~
# srand_from(0)
# var a = 10.rand
# var b = 100.rand
# srand_from(0)
# assert 10.rand == a
# assert 100.rand == b
# ~~~~
fun srand_from(x: Int) `{ nit_rand_seeded = 1; nit_rand_seed = (unsigned int)x; `}
lib/core/math.nit:557,1--569,82