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

10 lines
273 B
Plaintext
Raw Permalink Normal View History

2020-09-08 18:38:05 -07:00
data List a = { Nil, Cons a (List a) }
data Bool = { True, False }
defn length l = {
case l of {
Nil -> { 0 }
Cons x xs -> { 1 + length xs }
}
}
defn main = { length (Cons 1 (Cons 2 (Cons 3 Nil))) + length (Cons True (Cons False (Cons True Nil))) }