2 ms·
I disagree, because a has two recursive calls. In that case you can't make both calls to a into tail calls.
by tome 9y ago
I disagree, because a has two recursive calls. In that case you can't make both calls to a into tail calls.
- Jtsummers 9y agoWell, if you're hung up on the OP's code, they do the same thing twice so we could maybe just double the result when we put it into the accumulator. If you read what I wrote I've qualified my statements properly. Not everything in the OP's form will be able to be made tail recursive. But the form they presented does not bar tail recursion and efficienct tail recursion at that. Anything that can't be made efficient recursively would likely also use gobs of memory and time if constructed iteratively.