4 ms·
Sure, but depending on the recursion, that technique will vary from "inelegant" to "maddeningly brittle". It seems like going pretty far just to avoid recursio
by pcstl 7y ago
Sure, but depending on the recursion, that technique will vary from "inelegant" to "maddeningly brittle".
It seems like going pretty far just to avoid recursion, unless you're in a resource-constrained domain.
- BubRoss 7y agoThere is nothing brittle about it, you push values to the stack instead of passing them to a function (which just pushes them to the call stack). It actually ends up being far less brittle in practice because it is much easier to deal with edge cases and errors. You can break out of a loop much easier than returning different values and having those bubble up.