Skip to content

Instantly share code, notes, and snippets.

@fffej
Created June 1, 2010 06:19
Show Gist options
  • Save fffej/420631 to your computer and use it in GitHub Desktop.
Save fffej/420631 to your computer and use it in GitHub Desktop.
withinBounds :: (Double,Double) -> Bool
withinBounds (x,y) = (x**2+y**2) < 1.0
estimatePi :: [(Double,Double)] -> Double
estimatePi xs = 4.0 * within / len
where
len = fromIntegral $ length xs
within = fromIntegral $ length $ filter withinBounds xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment