July 2018
Intermediate to advanced
574 pages
14h 7m
English
We will now talk about a different way of processing collections, which, as functional programming, may require a shift in your mindset. Before talking about lazy processing, let's enumerate some of the shortcomings of working with the Enum module. The Enum module is referred to as being eager. This means that when processing a collection, this module will load the entire collection into memory. Furthermore, if you have a chain of functions you want to apply to a collection, the Enum module will iterate through your collection as many times as the functions are applying to it. Let's examine this further with an example:
iex> [1, 2, 3, 4, 5] \...> |> Enum.map(&(&1 + 10)) \...> |> Enum.zip(["a", "b", "c", ...
Read now
Unlock full access