up previous next
seed for
random
***** NOT YET IMPLEMENTED *****
This function seeds the random number generator,
random
.
NOTE: every time you restart CoCoA the sequence of random numbers will
be the same (as happens in many programming languages). If you want better
randomness, see the example below.
Seed(5);
Rand();
1991603592
-------------------------------
Rand();
-1650270230
-------------------------------
Seed(5); -- with the same seed, "Rand" generates the same sequence
Rand();
1991603592
-------------------------------
Rand();
-1650270230
-------------------------------
-- Better randomness:
-- the following shows how to make a random seed based on the date.
D := Date();
D;
Mon Mar 02 14:43:44 1998
-------------------------------
Seed(Sum(Ascii(D)));
|