Recursive Functions
In this lesson, you will be given a brief introduction to recursion and go over how recursion is implemented in Scala.
Recursive functions play an essential role in functional programming. But what are recursive functions?
Recursive functions are functions which call themselves in their own function body. This may seem a bit strange right now, but let’s see how this works.
Recursion
Recursion is the process of breaking down an expression into smaller and smaller expressions until you’re able to use the same algorithm to solve each expression.
A recursive function is made up of an if-else
expression. The if
represents the base case which is the smallest possible expression on which an algorithm will run and the else
...