I love these types of functional examples because they showcase real situations that benefit from tail-call optimization. Some languages (e.g. Haskell, Scheme) are optimized for this sort of recursion. That means the equivalent Haskell program would actually not cause a stack overflow. This is vital considering Haskell has no concept of an iterative loop, so recursive functions like this are sometimes the only way to express certain logical behaviors 🙂
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I love these types of functional examples because they showcase real situations that benefit from tail-call optimization. Some languages (e.g. Haskell, Scheme) are optimized for this sort of recursion. That means the equivalent Haskell program would actually not cause a stack overflow. This is vital considering Haskell has no concept of an iterative loop, so recursive functions like this are sometimes the only way to express certain logical behaviors 🙂