VectorFunctions2(A, B)ΒΆ

vector.spad line 192

This package provides operations which all take as arguments vectors of elements of some type A and functions from A to another of type B. The operations all iterate over their vector argument and either return a value of type B or a vector over B.

map: (A -> B, Vector A) -> Vector B
map(f, v) applies the function f to every element of the vector v producing a new vector containing the values.
map: (A -> Union(B, failed), Vector A) -> Union(Vector B, failed)
map(f, v) applies the function f to every element of the vector v producing a new vector containing the values or "failed".
reduce: ((A, B) -> B, Vector A, B) -> B
reduce(func, vec, ident) combines the elements in vec using the binary function func. Argument ident is returned if vec is empty.
scan: ((A, B) -> B, Vector A, B) -> Vector B
scan(func, vec, ident) creates a new vector whose elements are the result of applying reduce to the binary function func, increasing initial subsequences of the vector vec, and the element ident.