lily/programs/length.lily

9 lines
210 B
Plaintext

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