A.Vector.foldr

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

Specs

foldr(t(val), acc, (val, acc -> acc)) :: acc when val: value(), acc: term()

Folds (reduces) the given vector from the right with the function fun. Requires an accumulator acc.

Unlike linked lists, this is as efficient as foldl/3. This can typically save a call to Enum.reverse/1 on the result when building a list.

Runs in linear time.

Examples

iex> A.Vector.new(1..10) |> A.Vector.foldr(0, &+/2)
55
iex> A.Vector.new(1..10) |> A.Vector.foldr([], & [&1 | &2])
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]