Stream.map_every
You're seeing just the function
map_every
, go back to Stream module for more information.
Specs
map_every(Enumerable.t(), non_neg_integer(), (element() -> any())) :: Enumerable.t()
Creates a stream that will apply the given function on
every nth
element from the enumerable.
The first element is always passed to the given function.
nth
must be a non-negative integer.
Examples
iex> stream = Stream.map_every(1..10, 2, fn x -> x * 2 end)
iex> Enum.to_list(stream)
[2, 2, 6, 4, 10, 6, 14, 8, 18, 10]
iex> stream = Stream.map_every([1, 2, 3, 4, 5], 1, fn x -> x * 2 end)
iex> Enum.to_list(stream)
[2, 4, 6, 8, 10]
iex> stream = Stream.map_every(1..5, 0, fn x -> x * 2 end)
iex> Enum.to_list(stream)
[1, 2, 3, 4, 5]