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