/usr/share/axiom-20170501/src/algebra/VECTOR2.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | )abbrev package VECTOR2 VectorFunctions2
++ Description:
++ This package provides operations which all take as arguments
++ vectors of elements of some type \spad{A} and functions from \spad{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.
VectorFunctions2(A, B) : SIG == CODE where
A : Type
B : Type
VA ==> Vector A
VB ==> Vector B
O2 ==> FiniteLinearAggregateFunctions2(A, VA, B, VB)
UB ==> Union(B,"failed")
SIG ==> with
scan : ((A, B) -> B, VA, B) -> VB
++ 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.
reduce : ((A, B) -> B, VA, B) -> B
++ reduce(func,vec,ident) combines the elements in vec using the
++ binary function func. Argument ident is returned if vec is empty.
map : (A -> B, VA) -> VB
++ map(f, v) applies the function f to every element of the vector v
++ producing a new vector containing the values.
map : (A -> UB, VA) -> Union(VB,"failed")
++ map(f, v) applies the function f to every element of the vector v
++ producing a new vector containing the values or \spad{"failed"}.
CODE ==> add
scan(f, v, b) == scan(f, v, b)$O2
reduce(f, v, b) == reduce(f, v, b)$O2
map(f:(A->B), v:VA):VB == map(f, v)$O2
map(f:(A -> UB), a:VA):Union(VB,"failed") ==
res : List B := []
for u in entries(a) repeat
r := f u
r = "failed" => return "failed"
res := [r::B,:res]
vector reverse! res
|