Stream.scan
You're seeing just the function
scan
, go back to Stream module for more information.
Specs
scan(Enumerable.t(), (element(), acc() -> any())) :: Enumerable.t()
Creates a stream that applies the given function to each element, emits the result and uses the same result as the accumulator for the next computation. Uses the first element in the enumerable as the starting value.
Examples
iex> stream = Stream.scan(1..5, &(&1 + &2))
iex> Enum.to_list(stream)
[1, 3, 6, 10, 15]
Specs
scan(Enumerable.t(), acc(), (element(), acc() -> any())) :: Enumerable.t()
Creates a stream that applies the given function to each
element, emits the result and uses the same result as the accumulator
for the next computation. Uses the given acc
as the starting value.
Examples
iex> stream = Stream.scan(1..5, 0, &(&1 + &2))
iex> Enum.to_list(stream)
[1, 3, 6, 10, 15]