Witchcraft.Foldable.Proto protocol (Witchcraft v1.0.4) View Source
Protocol for the Elixir.Witchcraft.Foldable
type class
For this type class's API, please refer to Elixir.Witchcraft.Foldable
Link to this section Summary
Functions
Right-associative fold over a structure to alter the structure and/or reduce it to a single summary value. The right-association makes it possible to cease computation on infinite streams of data.
Link to this section Types
Specs
t() :: term()
Link to this section Functions
Specs
Right-associative fold over a structure to alter the structure and/or reduce it to a single summary value. The right-association makes it possible to cease computation on infinite streams of data.
The folder must be a binary function, with the second argument being the accumulated value thus far.
Examples
iex> sum = fn xs -> right_fold(xs, 0, &+/2) end
iex> sum.([1, 2, 3])
6
iex> sum.([4, 5, 6])
15