Elixir provides a set of functions that enumerate over collections which implement the
Enumerable protocol. These collections include lists and maps.
Enum.filter/2 takes two parameters:
- a collection, and
- a function which returns a
Filtering a list:
Note that the functions in the
Enummodule are eager. The
Streammodule allows lazy enumeration of enumerables and provides infinite streams.
A lazy filter using streams: