Creating Higher-Order Functions for Lists

Using functions in variables, like with any other value, can be hard to remember for newcomers. To practice, we’ll work with a subject familiar to us: lists. They’re a useful data type and are present in almost any program we need to build. We’ve seen how to work with them using recursive functions, but if we stop and look again at all that code we’ve written, we’ll see that they are a little bit repetitive and boring. We always have code that navigates through each item, and a stop condition when the list is empty. It’s time to change it! We’ll look at how to build higher-order functions that hide the tedious tasks and provide an interface for what matters. Let’s start with the navigation routine.

Navigating ...

Get Learn Functional Programming with Elixir now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.