Elixir Function of the Day

A start page for alchemists! Roll the dice.



Function signature:

scan(enumerable, fun)


Applies the given function to each element in the enumerable, storing the result in a list and passing it as the accumulator for the next computation. Uses the first element in the enumerable as the starting value.


iex> Enum.scan(1..5, &(&1 + &2))
[1, 3, 6, 10, 15]