
22 Dec
2009
22 Dec
'09
2:39 p.m.
On Tue, Dec 22, 2009 at 1:16 PM, Scott Turner <1haskell@pkturner.org> wrote:
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)
That's correct. randomRIO uses the global random number generator which is automatically initialized with a different seed each time your program starts up.
but you can always change it with setStdGen, and you can always use the non-IO part of System.Random (or even another random library altogether, particularly recommended if you need performances as System.Random is more than slow). -- Jedaï