[Haskell-cafe] How can i set the seed random number generator ?

zaxis z_axis at 163.com
Mon Dec 21 20:37:30 EST 2009

In erlang, first i use the following function to set the seed:
new_seed() ->
    {_,_,X} = erlang:now(),
    {H,M,S} = time(),
    H1 = H * X rem 32767,
    M1 = M * X rem 32767,
    S1 = S * X rem 32767,
    put(random_seed, {H1,M1,S1}).

then use random:uniform/1 to get the random number.

In haskell, i just use the following function to get the random number. It
seems i donot need to set the seed of random number generator manually?

rollDice ::  Int -> IO Int
rollDice n = randomRIO(1,n)


fac n = foldr (*) 1 [1..n]
View this message in context: http://old.nabble.com/How-can-i-set-the-seed-random-number-generator---tp26882798p26882798.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list