Chapter 4Diving into Recursion
A simple script that counts to 10, a homepage that shows recent news, a program that parses each line of a CSV file. What do these programs have in common? They all need to do repetitive tasks to determine the final result. Recursive functions are the core of repetition in functional programming.
In imperative languages, the repetition is done using iterative features like for and while loops, which rely on mutable state. In functional programming, we have the immutable state, so we need a different approach. Here we use recursive functions.
A recursive function is when a function calls itself, leading to successive calls of the same function. In this chapter, we’ll look at strategies to work with recursion and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access