mirror of
https://github.com/anoma/juvix.git
synced 2024-12-12 14:28:08 +03:00
29 lines
350 B
Plaintext
29 lines
350 B
Plaintext
-- higher-order functions & recursion
|
|
|
|
function f(integer -> integer) : integer {
|
|
push 5;
|
|
push arg[0];
|
|
tcall $ 1;
|
|
}
|
|
|
|
function h(integer, integer) : integer {
|
|
push arg[1];
|
|
push arg[0];
|
|
add;
|
|
ret;
|
|
}
|
|
|
|
function u(integer) : integer {
|
|
push arg[0];
|
|
push 4;
|
|
calloc h 1;
|
|
call f;
|
|
add;
|
|
ret;
|
|
}
|
|
|
|
function main() {
|
|
push 2;
|
|
tcall u;
|
|
}
|