blog-static/code/compiler/08/examples/works3.txt

9 lines
191 B
Plaintext
Raw Normal View History

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