Created
June 1, 2010 06:19
-
-
Save fffej/420631 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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