Part Seven | Functional Programming Through Elixir: Higher-Order Functions
Beyond Passing Functions Around
In Part Six, we saw how the pipe operator turns nested function calls into readable pipelines. In Part Two, we learned that functions are values. You can pass them to Enum.map and Enum.filter to transform and select data.
Now we’ll go deeper. A higher-order function is a function that does at least one of these things:
- Takes a function as an argument (like
Enum.map) - Returns a function as its result
You’ve already used higher-order functions when calling Enum.map and Enum.filter. This post covers the most important one you haven’t seen yet, reduce, then gets into writing your own higher-order functions and composing functions together.