her.esy.fun/src/posts/0010-Haskell-Now/evenSum_v2.hs
Yann Esposito (Yogsototh) 7784f02483
wip
2019-12-25 16:35:56 +01:00

12 lines
348 B
Haskell

-- Version 2
evenSum :: Integral a => [a] -> a
evenSum l = accumSum 0 l
where accumSum n l =
if l == []
then n
else let x = head l
xs = tail l
in if even x
then accumSum (n+x) xs
else accumSum n xs