Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.List (foldl')
- avg list =
- let (count, sum) = foldl' collect (0, 0) list
- in fromIntegral sum / count
- where
- collect (count, sum) item =
- count `seq`
- sum `seq`
- (count + 1, sum + item)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement