An enumerable is a data structure that implements the contract required by Enum operations. It lets iteration helpers hide recursive and tail-recursive boilerplate behind concise calls. section 3.4.3
Common enumerable operations include:
- Enum.each/2 visits every element and applies a function. section 3.4.3
- Enum.map/2 transforms each element into a new enumerable result. section 3.4.3
- Enum.filter/2 retains elements matching a predicate, while Enum.reduce/3 accumulates a result. section 3.4.3
- Lists, ranges, maps, and MapSet are examples; custom data structures can also implement the required contract. section 3.4.3
Traversing an enumerable
Enum.each([1, 2, 3], fn x -> IO.puts(x) end) prints each element without explicit recursion. section 3.4.3
