Created
August 8, 2015 06:58
-
-
Save dermusikman/f7df5030828dae5d4a3d to your computer and use it in GitHub Desktop.
(╯°□°)╯︵ ןןǝʞsɐɥ
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
me@le-me $ cat scratch.hs | |
evenSum :: Integral a => [a] -> a | |
evenSum l = accumSum 0 l | |
where | |
accumSum n [] = n | |
accumSum n (x:xs) = | |
if even x | |
then accumSum (n+x) xs | |
else accumSum x xs | |
evenSum' :: Integral a => [a] -> a | |
evenSum' l = accumSum 0 l | |
where | |
accumSum n [] = n | |
accumSum n (x:xs) = | |
if even x | |
then accumSum (n+x) xs | |
else accumSum n xs | |
main = do | |
print $ evenSum [1..5] | |
print $ evenSum' [1..5] | |
me@le-me $ ./scratch | |
5 | |
6 |
Author
dermusikman
commented
Aug 8, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment