O'Reilly logo

Pragmatic Scala by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required