Enum.chunk_while/4
defmodule Enum do
def chunk_while(enumerable, acc, chunk_fun, after_fun)
end
Chunks enumerable
with fine grained control when every chunk is emitted.
chunk_fun
receives the current element and the accumulator and must return
{:cont, chunk, acc}
to emit the given chunk and continue with accumulator or{:cont, acc}
to not emit any chunk and continue with the return accumulator.
after_fun
is invoked when iteration is done and must also return {:cont, chunk, acc}
or {:cont, acc}
.
The iteration stops as soon as chunk_fun
returns a tuple of the form {:halt, acc}
.