27.41 RandomList

RandomList( list )

RandomList returns a random element of the list list. The results are equally distributed, i.e., all elements are equally likely to be selected.

    gap> RandomList( [1..200] );
    192
    gap> RandomList( [1..200] );
    152
    gap> RandomList( [ [ 1, 2 ], 3, [ 4, 5 ], 6 ] );
    [ 4, 5 ] 

RandomSeed( n )

RandomSeed seeds the pseudo random number generator RandomList. Thus to reproduce a computation exactly you can call RandomSeed each time before you start the computation. When GAP is started the pseudo random number generator is seeded with 1.

    gap> RandomSeed(1);  RandomList([1..100]);  RandomList([1..100]);
    96
    76
    gap> RandomSeed(1);  RandomList([1..100]);  RandomList([1..100]);
    96
    76 

RandomList is called by all random functions for domains (see Random).

Previous Up Top
Index

GAP 3.4.4
April 1997