1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-03 09:41:10 +03:00
juvix/tests/Core/benchmark/test003.jvc

14 lines
343 B
Plaintext

-- tail recursion through higher-order functions
def sumb := \f \x \acc if x = 0 then acc else f (x - 1) acc;
def sum' := \x \acc sumb sum' x (x + acc);
def sum := \x sum' x 0;
def writeLn := \x write x >> write "\n";
writeLn (sum 10000) >>
writeLn (sum 100000) >>
writeLn (sum 1000000) >>
writeLn (sum 10000000) >>
writeLn (sum 100000000)