mirror of
https://github.com/anoma/juvix.git
synced 2024-12-12 14:28:08 +03:00
94 lines
1.1 KiB
Plaintext
94 lines
1.1 KiB
Plaintext
-- mutual recursion
|
|
|
|
function g(integer) : integer;
|
|
|
|
function f(integer) : integer {
|
|
push 1;
|
|
push arg[0];
|
|
lt;
|
|
br {
|
|
true: {
|
|
push 1;
|
|
ret;
|
|
}
|
|
false: {
|
|
push 268435456;
|
|
push 1;
|
|
push arg[0];
|
|
sub;
|
|
call g;
|
|
push arg[0];
|
|
push 2;
|
|
mul;
|
|
add;
|
|
mod;
|
|
ret;
|
|
}
|
|
};
|
|
}
|
|
|
|
function h(integer) : integer;
|
|
|
|
function g(integer) : integer {
|
|
push 1;
|
|
push arg[0];
|
|
lt;
|
|
br {
|
|
true: {
|
|
push 1;
|
|
ret;
|
|
}
|
|
false: {
|
|
push 268435456;
|
|
push 1;
|
|
push arg[0];
|
|
sub;
|
|
call h;
|
|
push arg[0];
|
|
add;
|
|
mod;
|
|
ret;
|
|
}
|
|
};
|
|
}
|
|
|
|
function h(integer) : integer {
|
|
push 1;
|
|
push arg[0];
|
|
lt;
|
|
br {
|
|
true: {
|
|
push 1;
|
|
ret;
|
|
}
|
|
false: {
|
|
push 268435456;
|
|
push 1;
|
|
push arg[0];
|
|
sub;
|
|
call f;
|
|
push arg[0];
|
|
mul;
|
|
mod;
|
|
ret;
|
|
}
|
|
};
|
|
}
|
|
|
|
function main() {
|
|
push 5;
|
|
call f;
|
|
trace;
|
|
pop;
|
|
push 10;
|
|
call f;
|
|
trace;
|
|
pop;
|
|
push 100;
|
|
call f;
|
|
trace;
|
|
pop;
|
|
push void;
|
|
ret;
|
|
}
|