Stream.chunk_by

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

Specs

chunk_by(Enumerable.t(), (element() -> any())) :: Enumerable.t()

Chunks the enum by buffering elements for which fun returns the same value.

Elements are only emitted when fun returns a new value or the enum finishes.

Examples

iex> stream = Stream.chunk_by([1, 2, 2, 3, 4, 4, 6, 7, 7], &(rem(&1, 2) == 1))
iex> Enum.to_list(stream)
[[1], [2, 2], [3], [4, 4, 6], [7, 7]]