3 ms·
welllll, i definitely wouldn’t say for no benefit... recursion is a much more flexible construct than loops, and when you combine that with pattern matching you
by rickycook 8y ago
welllll, i definitely wouldn’t say for no benefit... recursion is a much more flexible construct than loops, and when you combine that with pattern matching you can do some really nifty things in a way that’s incredibly easy to reason about and add edge case handling to
- millstone 8y agoEvery mainstream language supports recursion. If it also supports loops, like most do, then loops are used more often, because they're more flexible (example: early-exit).
- tome 8y agoNot every mainstream language supports tail call optimisation. Without TCO, rewriting loops as recursive functions is a bad idea.