September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,5 +1,19 @@
|
|||
{-# LANGUAGE BangPatterns #-}
|
||||
import Data.List (foldl')
|
||||
mean :: (Real n, Fractional m) => [n] -> m
|
||||
mean xs = let (s,l) = foldl' f (0, 0) xs in realToFrac s / l
|
||||
where f (!s,!l) x = (s+x,l+1)
|
||||
|
||||
import Data.List (foldl') --'
|
||||
|
||||
mean
|
||||
:: (Real n, Fractional m)
|
||||
=> [n] -> m
|
||||
mean xs =
|
||||
let (s, l) =
|
||||
foldl' --'
|
||||
f
|
||||
(0, 0)
|
||||
xs
|
||||
in realToFrac s / l
|
||||
where
|
||||
f (!s, !l) x = (s + x, l + 1)
|
||||
|
||||
main :: IO ()
|
||||
main = print $ mean [1 .. 100]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue