f0a02a1f520e14d00b5c324fd7bdc5fbd04d487255bc8752b96b55861b551a98

Download raw

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

Size: 667

Preview (limited to 512 bytes)

"module Main (main) where\n\nimport Data.List (unfoldr, foldl')\nimport System.Random.SplitMix32\n\ndoubles :: SMGen -> [Float]\ndoubles = unfoldr (Just . nextFloat)\n\nmonteCarloPi :: SMGen -> Float\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