A.Vector.scan

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

Specs

scan(t(val), (val, val -> val)) :: val when val: value()

Applies the given function to each element in the vector, storing the result in a vector and passing it as the accumulator for the next computation.

Uses the first element in the vector as the starting value.

Runs in linear time.

Examples

iex> A.Vector.new(1..10) |> A.Vector.scan(&+/2)
vec([1, 3, 6, 10, 15, 21, 28, 36, 45, 55])

Specs

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

Applies the given function to each element in the vector, storing the result in a vector and passing it as the accumulator for the next computation.

Uses the given acc as the starting value.

Runs in linear time.

Examples

iex> A.Vector.new(1..10) |> A.Vector.scan(100, &+/2)
vec([101, 103, 106, 110, 115, 121, 128, 136, 145, 155])