3 ms·
Well, I wasn't offering an opinion as to when recursion should be used--merely pointing out that the GP's proposed change didn't hold the same meaning as the or
by unclebucknasty 9y ago
Well, I wasn't offering an opinion as to when recursion should be used--merely pointing out that the GP's proposed change didn't hold the same meaning as the original.
>never unless you happen to have unbounded call stack depth.
But, since you mention it, I'd have to disagree with your assertion. It's not just about call stack-depth or artificial limitations. There are plenty of use-cases wherein the search-space-depth itself is naturally bound, but unknown/variable down any particular path (e.g. category hierarchies). And, yes, we can impose reasonable "manual" limitations on still more use-cases to expand this universe even further.
Using recursion in these cases is far more elegant than nested loops.
- AstralStorm 9y agoThat falls under "proved it cannot happen with a formal proof". If you didn't actually prove it you're playing with fire. Funny thing is that proofs over recursive functions are either very easy or terribly involved. Also it is a false dichotomy. Nested loops are not the only option.