lily/programs/length.lily

9 lines
210 B
Plaintext
Raw Permalink Normal View History

2019-06-12 08:53:54 -07:00
data IntList = { Nil, Cons(Int, IntList) }
2019-06-04 17:12:24 -07:00
defn length l = {
case l of {
Nil -> { 0 }
Cons(x, xs) -> { 1 + length xs }
}
}
2019-06-12 08:53:54 -07:00
defn main = { length (Cons 1 (Cons 2 (Cons 3 (Cons 4 Nil)))) }