
17 Dec
2002
17 Dec
'02
8:51 a.m.
Mark Carroll 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 -kzm -- If I haven't seen further, it is by standing in the footprints of giants