Created
July 8, 2015 12:16
-
-
Save astarasikov/c4506f456dd69e6a844e to your computer and use it in GitHub Desktop.
average
This file contains hidden or 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
| avg [] curr n = curr | |
| avg (x:xs) curr n = | |
| let c' = (x + (curr * n)) / (n + 1) | |
| in avg xs c' (n + 1) | |
| avg' lst = avg lst 0 0 | |
| main = | |
| print $ avg' ([1, 2, 3, 4, 5] :: [Double]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment