lily/programs/sum.lily

9 lines
201 B
Plaintext

data IntList = { Nil, Cons(Int, IntList) }
defn sum l = {
case l of {
Nil -> { 0 }
Cons(x, xs) -> { x + sum xs }
}
}
defn main = { sum (Cons 1 (Cons 2 (Cons 3 (Cons 4 Nil)))) }