Enum.map_every
You're seeing just the function
map_every
, go back to Enum module for more information.
Specs
map_every(t(), non_neg_integer(), (element() -> any())) :: list()
Returns a list of results of invoking fun
on every nth
element of enumerable
, starting with the first element.
The first element is always passed to the given function, unless nth
is 0
.
The second argument specifying every nth
element must be a non-negative
integer.
If nth
is 0
, then enumerable
is directly converted to a list,
without fun
being ever applied.
Examples
iex> Enum.map_every(1..10, 2, fn x -> x + 1000 end)
[1001, 2, 1003, 4, 1005, 6, 1007, 8, 1009, 10]
iex> Enum.map_every(1..10, 3, fn x -> x + 1000 end)
[1001, 2, 3, 1004, 5, 6, 1007, 8, 9, 1010]
iex> Enum.map_every(1..5, 0, fn x -> x + 1000 end)
[1, 2, 3, 4, 5]
iex> Enum.map_every([1, 2, 3], 1, fn x -> x + 1000 end)
[1001, 1002, 1003]