Recursion and Effects
Learn about the characteristics of recursion in functional programming and about the conditions that we try to avoid.
We'll cover the following
Recursion
In functional programming, we say we prefer recursion over looping to iterate over collections. That’s because looping relies on a state to iterate over a collection, while in recursion, we don’t need to do that. Plus, it fits better with the functional programming guidelines.
A recursive call happens when it’s done inside the scope of the function being called. So basically, it’s a function invoking itself, letting the logic be repeated until it reaches the base case. A well-known challenge in introducing recursion is the calculation of the factorial formula:
Get hands-on with 1400+ tech skills courses.