4 ms·
All the examples are tail recursive, which is exactly equivalent to looping. All you're going to achieve by doing this is to get an inaccurate understanding of
by peterkelly 6y ago
All the examples are tail recursive, which is exactly equivalent to looping. All you're going to achieve by doing this is to get an inaccurate understanding of what recursion actually is.
Practicing working with true recursion would involve algorithms that are not tail-recursive, such as tree traversal.
Just read SICP. You can thank me later.
- lmilcin 6y agoStill, even when tail recursive it is useful when it ends up with clean code. But then if you want to read it you still have to understand what it is tail recursion and whether it applies in particular case.
- 8note 6y agoA nice thing about tail recursion is having a in interface for what the loop requires at the start. Putting a function call in a loop maybe does that more clearly though