blog-static/code/compiler/11/examples/works4.txt
Danila Fedorin d7846e0b32
Some checks failed
continuous-integration/drone/push Build is failing
Fork off code for part 11 of compiler series.
2020-04-09 23:48:53 -07:00

17 lines
328 B
Plaintext

data List = { Nil, Cons Int List }
defn add x y = { x + y }
defn mul x y = { x * y }
defn foldr f b l = {
case l of {
Nil -> { b }
Cons x xs -> { f x (foldr f b xs) }
}
}
defn main = {
foldr add 0 (Cons 1 (Cons 2 (Cons 3 (Cons 4 Nil)))) +
foldr mul 1 (Cons 1 (Cons 2 (Cons 3 (Cons 4 Nil))))
}