[Haskell-cafe] Monte Carlo Pi calculation (newbie learnings)

Henning Thielemann lemming at henning-thielemann.de
Tue Nov 6 08:48:29 EST 2007


On Mon, 5 Nov 2007, Andrew Coppin wrote:

>   randList :: Int -> IO [Int]
>   randList n = mapM (\x -> randomRIO (0, randMax)) [1..n]

replicateM n (randomRIO (0, randMax))

but it is certainly better to use randomR and wrap it in a State monad


More information about the Haskell-Cafe mailing list