Enum (each / map / sum)
Iteration/transformation over collections.
Syntax
Enum.each(collection, fn) Enum.map(...) Enum.sum(...)
Description
In Elixir, Enum is used instead of loops. each performs an action on each element, map transforms, sum adds up. 1..n is a range.
Example
Loading editor…
Expected output
1 2 3 [1, 4, 9] 5050
When to use?
List processing, transformation, reduction (map/filter/reduce).