Stream.take_every

You're seeing just the function take_every, go back to Stream module for more information.

Specs

take_every(Enumerable.t(), non_neg_integer()) :: Enumerable.t()

Creates a stream that takes every nth element from the enumerable.

The first element is always included, unless nth is 0.

nth must be a non-negative integer.

Examples

iex> stream = Stream.take_every(1..10, 2)
iex> Enum.to_list(stream)
[1, 3, 5, 7, 9]

iex> stream = Stream.take_every([1, 2, 3, 4, 5], 1)
iex> Enum.to_list(stream)
[1, 2, 3, 4, 5]

iex> stream = Stream.take_every(1..1000, 0)
iex> Enum.to_list(stream)
[]