4 ms·
I don't really get the point of this. As far as I can tell, the code is doing the same thing as before but has become (at least to me) much harder to understand
by gweinberg 8y ago
I don't really get the point of this. As far as I can tell, the code is doing the same thing as before but has become (at least to me) much harder to understand.
- mcguire 8y agoIf the argument to the original function is too large, the function runs out of stack space for the recursion. The function at the end of the post handles much larger arguments. The presentation is very complicated, though.
- ericlippert 8y agoThe point is to demonstrate the general truth that any method with a single recursion can be turned into a loop by making a series of small, safe program transformations. It is not intended to be a demonstration of a technique for writing more understandable code.