A.Vector.split_while
You're seeing just the function
split_while
, go back to A.Vector module for more information.
Specs
Splits vector
in two at the position of the element for which fun
returns a falsy value
(false
or nil
) for the first time.
It returns a two-element tuple with two vectors of elements. The element that triggered the split is part of the second vector.
Is basically performing take_while/2
and drop_while/2
at once.
Runs in linear time.
Examples
iex> {taken, dropped} = A.Vector.new(1..10) |> A.Vector.split_while(fn x -> x < 7 end)
iex> taken
vec([1, 2, 3, 4, 5, 6])
iex> dropped
vec([7, 8, 9, 10])