Heads and Tails
Explore how recursion is a natural approach to processing lists in Elixir. Understand the head and tail structure of lists and practice writing functions such as length calculation and list transformations to strengthen your functional programming skills.
We'll cover the following...
We'll cover the following...
When we program with lists in conventional languages, we treat them as things to be iterated, meaning that it seems natural to loop over them. So, why do we have a chapter on lists and recursion? Because if we look at the problem in the right way, recursion is a perfect tool for processing lists.
Heads and tails
Earlier, we said a list may either be empty or consist of a head and a tail. The head contains a ...