Chapter 28
Recursion
Recursion first appeared in this book in chapter 6 when it was used to provide basic iteration. This was extended upon in chapter 15 where the memory of the stack was utilized with recursive functions that call themselves more than once. This chapter will revisit the concept of recursion to help solidify it in your mind.1 The next three chapters will utilize recursion, making this an ideal time to provide a refresher and integrate it into our project.
28.1 Refresher
A recursive function is nothing more than a function that calls itself. This means that it is defined in terms of itself. This seemingly circular type of definition works because all recursive functions need some form of base case where they do not call themselves. ...
Get Introduction to the Art of Programming Using Scala now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.