Tutorial by Examples

Using regular recursion, each recursive call pushes another entry onto the call stack. When the recursion is completed, the application has to pop each entry off all the way back down. If there are much recursive function calls it can end up with a huge stack. Scala automatically removes the recurs...
It is very common to get a StackOverflowError error while calling recursive function. Scala standard library offers TailCall to avoid stack overflow by using heap objects and continuations to store the local state of the recursion. Two examples from the scaladoc of TailCalls import scala.util.cont...

Page 1 of 1