Code:
Note there are no specialization annotations (@), adding halt annotations ($) doesnt seem to help either.
fn subber(a: int, b: int) -> int {
a - b
}
fn fac_rec(n : int, muter: fn(int) -> int) -> int {
if (n <= 0) {
1
} else {
let nn = muter(n);
n * $fac_rec(nn, muter)
}
}
fn fac_nrec(n : int) -> int {
let subber1 = |x: int| subber(x, 1);
fac_rec(n, subber1)
}
fn main() -> int {
fac_nrec(5)
//if @fac_rec(5) == 120 { 0 } else { 1 }
}
This same code is trivially runnable in JS console:
(function(){
var s=(a,b)=>a-b;
var s1=(a)=>s(a,1);
function fac_rec(n, muter){
if(n<=0){ return 1} else {return n*fac_rec(muter(n),muter)}
}
console.log(fac_rec(5,s1));
})()
Code:
Note there are no specialization annotations (@), adding halt annotations ($) doesnt seem to help either.
This same code is trivially runnable in JS console: