/usr/share/axiom-20170501/src/algebra/ARRAY12.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 52 53 54 | )abbrev package ARRAY12 OneDimensionalArrayFunctions2
++ Description:
++ This package provides tools for operating on one-dimensional arrays
++ with unary and binary functions involving different underlying types
OneDimensionalArrayFunctions2(A,B) : SIG == CODE where
A : Type
B : Type
VA ==> OneDimensionalArray A
VB ==> OneDimensionalArray B
O2 ==> FiniteLinearAggregateFunctions2(A, VA, B, VB)
SIG ==> with
scan : ((A, B) -> B, VA, B) -> VB
++ scan(f,a,r) successively applies
++ \spad{reduce(f,x,r)} to more and more leading sub-arrays
++ x of one-dimensional array \spad{a}.
++ More precisely, if \spad{a} is \spad{[a1,a2,...]}, then
++ \spad{scan(f,a,r)} returns
++ \spad{[reduce(f,[a1],r),reduce(f,[a1,a2],r),...]}.
++
++X T1:=OneDimensionalArrayFunctions2(Integer,Integer)
++X adder(a:Integer,b:Integer):Integer == a+b
++X scan(adder,[i for i in 1..10],0)$T1
reduce : ((A, B) -> B, VA, B) -> B
++ reduce(f,a,r) applies function f to each
++ successive element of the
++ one-dimensional array \spad{a} and an accumulant initialized to r.
++ For example, \spad{reduce(_+$Integer,[1,2,3],0)}
++ does \spad{3+(2+(1+0))}. Note that third argument r
++ may be regarded as the identity element for the function f.
++
++X T1:=OneDimensionalArrayFunctions2(Integer,Integer)
++X adder(a:Integer,b:Integer):Integer == a+b
++X reduce(adder,[i for i in 1..10],0)$T1
map : (A -> B, VA) -> VB
++ map(f,a) applies function f to each member of one-dimensional array
++ \spad{a} resulting in a new one-dimensional array over a
++ possibly different underlying domain.
++
++X T1:=OneDimensionalArrayFunctions2(Integer,Integer)
++X map(x+->x+2,[i for i in 1..10])$T1
CODE ==> add
map(f, v) == map(f, v)$O2
scan(f, v, b) == scan(f, v, b)$O2
reduce(f, v, b) == reduce(f, v, b)$O2
|