Ketil Z. Malde ketil@ii.uib.no
17 Dec 2002 14:51:32 +0100

Mark Carroll <mark@chaos.x-philes.com> writes:

> The "dice" function gives you back the new state of the rng which maybe
> you should keep around to start the next set of rolls with. ("main" throws
> it away with "snd".) I'd certainly be interested to see how this could be
> written more nicely. I avoided making the list of die rolls an infinitely
> long lazy list in case we wanted to use the same RNG for other stuff too

Okay, since you've already done his homework for him... :-)

        main = do
                r <- newStdGen
                print (dice 4 r)

        dice :: Integer -> StdGen -> [Integer]
        dice n g = take n $ randomRs (1,6) g

If I haven't seen further, it is by standing in the footprints of giants