4 ms·
Trying to get Donald Knuth's Man or Boy test to run, but it dies with "Stack overflow.". Any ideas on how to make it run? fun A (k, x1, x2, x3, x4, x5) { pr
by JoelJacobson 9y ago
Trying to get Donald Knuth's Man or Boy test to run,
but it dies with "Stack overflow.".
Any ideas on how to make it run?
fun A (k, x1, x2, x3, x4, x5) {
print k;
fun B() {
k = k - 1;
return A(k, B, x1, x2, x3, x4);
}
if (k <= 0) {
return x4() + x5();
} else {
return B();
}
}
fun F(i) {
fun G() {
return i;
}
return G;
}
print A(10, F(1), F(-1), F(-1), F(1), F(0)); // expect: -67