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

18 lines
374 B
Plaintext
Raw Permalink Normal View History

2020-09-08 18:38:05 -07:00
data List a = { Nil, Cons a (List a) }
defn fix f = { let { defn x = { f x } } in { x } }
defn fixpointOnes fo = { Cons 1 fo }
defn sumTwo l = {
case l of {
Nil -> { 0 }
Cons x xs -> {
x + case xs of {
Nil -> { 0 }
Cons y ys -> { y }
}
}
}
}
defn main = { sumTwo (fix fixpointOnes) }