3 ms·
I was under the impression that Schemes generally compile down to continuation-passing-style, and hence in the case of something like Fibonacci one of the recur
by chriswarbo 11y ago
I was under the impression that Schemes generally compile down to continuation-passing-style, and hence in the case of something like Fibonacci one of the recursive calls would be performed as a tail call, whilst the other would become part of the continuation, e.g. something like:
function fib(n, k) {
if (n == 0) k(1);
if (n == 1) k(1);
fib(n-1, function(f_1) {
fib(n-2, function(f_2) {
k(f_1 + f_2);
});
});
}