[Haskell-cafe] random question
Ryan Ingram
ryani.spam at gmail.com
Wed Oct 7 19:52:36 EDT 2009
On Wed, Oct 7, 2009 at 2:28 PM, Michael Mossey <mpm at alumni.caltech.edu>wrote:
> I don't quite follow your response. I want a program that initializes the
> generator from the global generator because I want different behavior every
> time I run it. So it will need IO. That's what I was trying to demonstrate.
> And I was wondering if one can get around the difficulty of passing the
> generator from call to call by using newStdGen in this way.
>
You should only have to call newStdGen once:
main = do
g <- newStdGen
let (g1,g2) = split g
let xs = [1..10]
print $ shuffle g1 xs
print $ shuffle g2 xs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091007/63a622dc/attachment.html
More information about the Haskell-Cafe
mailing list