JuliaVectorFunctions2(A, B)ΒΆ
jobject.spad line 1349 [edit on github]
This package provides operations which all take as arguments Julia 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, JuliaVector A) -> JuliaVector B
map(f, v)
applies the functionf
to every element of the vectorv
producing a new vector containing the values.
- map: (A -> Union(B, failed), JuliaVector A) -> Union(JuliaVector B, failed)
map(f, v)
applies the functionf
to every element of the vectorv
producing a new vector containing the values or"failed"
.
- reduce: ((A, B) -> B, JuliaVector A, B) -> B
reduce(func, vec, ident)
combines the elements invec
using the binary functionfunc
. Argument ident is returned ifvec
is empty.
- scan: ((A, B) -> B, JuliaVector A, B) -> JuliaVector B
scan(func, vec, ident)
creates a new vector whose elements are the result of applying reduce to the binary functionfunc
, increasing initial subsequences of the vectorvec
, and the element ident.