her.esy.fun/src/posts/0010-Haskell-Now/evenSum_v4.hs

10 lines
229 B
Haskell
Raw Normal View History

2019-12-25 15:35:56 +00:00
-- Version 4
evenSum :: Integral a => [a] -> a
evenSum = accumSum 0
where
accumSum n [] = n
accumSum n (x:xs) =
if even x
then accumSum (n+x) xs
else accumSum n xs