Chapter 11Programming Recursions
The idea of recursion—solving a problem using solutions to its subproblems—is alluring. Many algorithms and problems are recursive in nature. Once we get the hang of it, designing solutions using recursion becomes highly expressive and intuitive.
In general, the biggest catch with recursions is stack overflow for large input values. But, thankfully that’s not so in Scala for specially structured recursions. In this chapter we explore the powerful tail call optimization techniques and the support classes baked into Scala and its library, respectively. Using these easy-to-access facilities, you can implement highly recursive algorithms and reap their benefits for really large input values without blowing out the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access