FiniteLinearAggregateFunctions2(S, A, R, B)ΒΆ
aggcat2.spad line 1 [edit on github]
S: Type
A: Join(LinearAggregate S, finiteAggregate)
R: Type
B: Join(LinearAggregate R, finiteAggregate)
FiniteLinearAggregateFunctions2
provides functions involving two FiniteLinearAggregates where the underlying domains might be different. An example of this might be creating a list of rational numbers by mapping a function across a list of integers where the function divides each integer by 1000.
- map: (S -> R, A) -> B
map(f, a)
applies functionf
to each member of aggregatea
resulting in a new aggregate over a possibly different underlying domain.
- reduce: ((S, R) -> R, A, R) -> R
reduce(f, a, r)
applies functionf
to each successive element of the aggregatea
and an accumulant initialized tor
. For example,reduce(_+\$Integer, [1, 2, 3], 0)
does3+(2+(1+0))
. Note: third argumentr
may be regarded as the identity element for the functionf
.
- scan: ((S, R) -> R, A, R) -> B
scan(f, a, r)
successively appliesreduce(f, x, r)
to more and more leading sub-aggregatesx
of aggregratea
. More precisely, ifa
is[a1, a2, ...]
, thenscan(f, a, r)
returns[reduce(f, [a1], r), reduce(f, [a1, a2], r), ...]
.