Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
13 lines (11 sloc) 293 Bytes
import System.Environment
import Text.Printf
import Data.List (foldl')
main = do
[d] <- map read `fmap` getArgs
printf "%f\n" (mean [1..d])
mean :: [Double] -> Double
mean xs = s / fromIntegral n
(n, s) = foldl' k (0, 0) xs
k (n, s) x = n `seq` s `seq` (n+1, s+x)
Something went wrong with that request. Please try again.