Very clean very powerful the way to comput stack usage. It can be useful sometimes
marta
· 1 year ago
very nice article panefsky! keep on
Johannes
· 8 months ago
This is also a prime example of tail recursion. A good compiler should be able to spot this and produce the same output for those two functions. The reasoning being that at the second recursive call to step_up() there is really no meaningful state to save on the stack, so rather than actually performing the recursive call we can just reuse the current stack frame by jumping back up to the top of the currently executing function (which is exactly what you're doing in the second solution).
It can be useful sometimes
keep on