[Haskell-cafe] How can i set the seed random number generator ?
chaddai.fouche at gmail.com
Tue Dec 22 09:39:39 EST 2009
On Tue, Dec 22, 2009 at 1:16 PM, Scott Turner <1haskell at 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
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).
More information about the Haskell-Cafe