943ea84fe879c8bd40f81065ac22613055de92a3147e327a9ff1429cf63588c2

Download raw

Created: 2023-12-19 03:40:10.302489 UTC

Size: 669

Preview (limited to 512 bytes)

"module Main (main) where\n\nimport Data.List (unfoldr, foldl')\nimport System.Random.SplitMix\n\ndoubles :: SMGen -> [Double]\ndoubles = unfoldr (Just . nextDouble)\n\nmonteCarloPi :: SMGen -> Double\nmonteCarloPi = (4 *) . calc . foldl' accum (P 0 0) . take 50000000 . pairs . doubles\n where\n calc (P n m) = fromIntegral n / fromIntegral m\n\n pairs (x : y : xs) = (x, y) : pairs xs\n pairs _ = []\n\n accum (P n m) (x, y) | x * x + y * y >= 1 = P n (m + 1)\n | otherwise = P (n +"


Casa is a service provided by the Haskell Foundation │ Originally developed by FP Complete