1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-04 06:23:13 +03:00
juvix/tests/Core/positive/test015.jvc

22 lines
423 B
Plaintext

-- local functions with free variables
def f := \x {
let g := \y x + y in
if x = 0 then f 10
else if x < 10 then \y g (f (x - 1) y)
else g
};
def g := \x \h x + h x;
def h := \x if x = 0 then 0 else g (x - 1) h;
def writeLn := \x write x >> write "\n";
writeLn (f 100 500) >> -- 600
writeLn (f 5 0) >> -- 25
writeLn (f 5 5) >> -- 30
writeLn (h 10) >> -- 45
writeLn (g 10 h) >> -- 55
writeLn (g 3 (f 10)) -- 16