From 9855dda31ad3fe6149e2646924be7f65102814dd Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 12 Jun 2019 08:59:31 -0700 Subject: [PATCH] Add a test for lazy evaluation. --- programs/lazy.lily | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 programs/lazy.lily diff --git a/programs/lazy.lily b/programs/lazy.lily new file mode 100644 index 0000000..b6139a0 --- /dev/null +++ b/programs/lazy.lily @@ -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 }