1 import "StandardLibrary"
5 """This function returns either 0 or 1 such that
6 the expected value is pi/4"""
7 approximatePi :: () -> <Random> Double
8 approximatePi () = if x*x + y*y < 1 then 1 else 0
13 averageOfNRepeats n f = sum [f () | n <- [1..n]] / fromInteger n
15 betterApproximatePi () = averageOfNRepeats 1000 approximatePi * 4
17 main = withSeed 13 (betterApproximatePi ())