2 ms·
Tail recursion for two recursive steps per invocation? I don't think so. (Hint: the "naive" implementation of fib that I refer to above is "fib (x + 1) = fib
by jrockway 17y ago
Tail recursion for two recursive steps per invocation? I don't think so.
(Hint: the "naive" implementation of fib that I refer to above is "fib (x + 1) = fib x + fib (x - 1)".)
- swannodette 17y agoWhat are you saying exactly? That fib shouldn't be defined in terms of tail recursion? Of course it doesn't have to be. But it's also the moment that you realize that for loops are entirely unnecessary and broken since they aren't composable the way functions are.
- jrockway 17y agoIteration and tail recursion are orthogonal. Yes, you can implement iteration in terms of function application. But no, the results of benchmarking "fib" won't make your favorite version win.