Add a test for lazy evaluation.
This commit is contained in:
parent
9d9c7b7e9f
commit
9855dda31a
17
programs/lazy.lily
Normal file
17
programs/lazy.lily
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
data IntList = { Nil, Cons(Int, IntList) }
|
||||||
|
|
||||||
|
defn ones = { Cons 1 ones }
|
||||||
|
defn zipSum l r = {
|
||||||
|
case l of {
|
||||||
|
Nil -> { 0 }
|
||||||
|
Cons(lv, lt) -> {
|
||||||
|
case r of {
|
||||||
|
Nil -> { 0 }
|
||||||
|
Cons(rv, rt) -> {
|
||||||
|
(lv + rv) + zipSum lt rt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defn main = { zipSum (Cons 0 (Cons 1 Nil)) ones }
|
Loading…
Reference in New Issue
Block a user