A.Vector.take_while

You're seeing just the function take_while, go back to A.Vector module for more information.

Specs

take_while(t(val), (val -> as_boolean(term()))) :: t(val) when val: value()

Takes the elements from the beginning of the vector while fun returns a truthy value.

Runs in linear time regarding the size of the returned subset.

Examples

iex> A.Vector.new(1..100) |> A.Vector.take_while(fn x -> x < 7 end)
vec([1, 2, 3, 4, 5, 6])
iex> A.Vector.new([1, true, %{}, nil, "abc"]) |> A.Vector.take_while(fn x -> x end)
vec([1, true, %{}])