Stream.with_index
You're seeing just the function
with_index
, go back to Stream module for more information.
Specs
with_index(Enumerable.t(), integer()) :: Enumerable.t()
Creates a stream where each element in the enumerable will be wrapped in a tuple alongside its index.
If an offset
is given, we will index from the given offset instead of from zero.
Examples
iex> stream = Stream.with_index([1, 2, 3])
iex> Enum.to_list(stream)
[{1, 0}, {2, 1}, {3, 2}]
iex> stream = Stream.with_index([1, 2, 3], 3)
iex> Enum.to_list(stream)
[{1, 3}, {2, 4}, {3, 5}]