From the course: Scala Essential Training

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Recursion

Recursion

- [Instructor] All right, welcome back. So now that we know how to define functions, it's time to explore the mechanism of functions calling themselves also known as recursion. So getting back to our favorite project under the Part One package, I'm going to right click and create a separate scholar application for this lesson. So I'm going to call us recursion and I'm going to make an object as before with a main method in case we need to test some himself. And in this lesson I'm going to give you some exercises. So what is recursion? Recursion is the mechanism by which a function can refer to itself. And this is the mechanism in which in functional programming we simulate repetition. So as I mentioned earlier, in the rest of this course, we will think in terms of expressions and therefore we will try to avoid instructions. That is expressions returning unit and that includes variables and loops. So we'll try to avoid…

Contents