Recursion
Recursion is one of the most used techniques in FP and it is the process of calling a function inside itself. The function that calls itself is a recursive function.
Recursion is best used for problems where a large problem can be broken down into a repetitive subproblem. As a recursive function calls itself to solve these subproblems, eventually the function will come across a subproblem that it can handle without calling itself. This is known as a base case, and it is needed to prevent the function from calling itself over and over again without stopping.
In the base case, the function does not call itself. However, when a function does have to call itself in order to deal with its subproblem, then this is known as a recursive case. So, there are two types of cases when using a recursive algorithm: base cases and recursive cases. It is important to remember that, when using recursion and when we are trying to solve a problem, we should ask ourselves: what is my base case and what...