1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-12 14:28:08 +03:00
juvix/tests/Asm/positive/test019.jva
2022-09-29 17:44:55 +02:00

35 lines
430 B
Plaintext

-- recursion through higher-order functions
function g(integer -> integer, integer) : integer {
push arg[1];
push 0;
eq;
br {
true: {
push 0;
ret;
}
false: {
push 1;
push arg[1];
sub;
push arg[0];
tcall $ 1;
}
};
}
function f(integer) : integer {
push arg[0];
calloc f 0;
call g;
push arg[0];
add;
ret;
}
function main() {
push 10;
tcall f;
}