The Recursion that Jumps
Pablo Henrique Aguilar (~pablo) |
Sometimes we have problems that are better solved using recursion than an explicit loop (e.g. for, while), we have one main problem using recursion: Our resources are limited!
What happens when those resources are full? We get the famous Stack Overflow, we can't have an unlimited stack (because of the limited resource and for safety). Some languages solve that problem for us by providing a feature called Tail Recursion Optimization (TCO) that prevents our callstack to grow up until Stackoverflow in a recursive function! You can read about Tail Recursion.
Unfortunately, like many languages, Python doesn't have TCO, but we can try to emulate that feature! The idea of this talk is to show you how can use it as simple as it's.
Understanding of recursion
Passionate for challenges, technology, good code.
Now, I work as a Backend Engineer at Wildlife Studios. Wildlife is one of the greatest mobile game company in the world, you can check out the games we made in the previous link!