The first Haskell solution.
The function `evenSum` returns the sum of all even numbers in a list:
> -- Version 1
> evenSum :: [Integer] -> Integer
>
> evenSum l = accumSum 0 l
>
> 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
To test a function you can use `ghci`:
% ghci
GHCi, version 7.0.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :load 11_Functions.lhs
[1 of 1] Compiling Main ( 11_Functions.lhs, interpreted )
Ok, modules loaded: Main.
*Main> evenSum [1..5]
6

Here is an example of execution[^2]:
[^2]: I know I'm cheating. But I will talk about non-strict later.
*Main> evenSum [1..5]
accumSum 0 [1,2,3,4,5]
1 is odd
accumSum 0 [2,3,4,5]
2 is even
accumSum (0+2) [3,4,5]
3 is odd
accumSum (0+2) [4,5]
4 is even
accumSum (0+2+4) [5]
5 is odd
accumSum (0+2+4) []
l == []
0+2+4
0+6
6

Coming from an imperative language all should seem right.
In reality many things can be improved.
First, we can generalize the type.
```
evenSum :: Integral a => [a] -> a
```

> main = do print $ evenSum [1..10]