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

Wrapping Up

Recursions provide a nice, intuitive, and expressive solution to many problems. However, programmers often either avoid recursions or are rather reluctant to use them because of the issue with stack overflow for large input values. The Scala compiler has built-in support to optimize recursions that are at the tail position into iterations, so you can avoid this problem. This optimization allows us to more liberally use recursions where it makes sense, without the worry of blowing out stacks. You also saw the Scala library support for working easily with trampoline recursions. Between these two solutions, solving critical algorithms and problems becomes a matter of writing just a few lines of code with fewer concerns to worry about. ...

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