FiniteLinearAggregateFunctions2(S, A, R, B)¶
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 function
fto each member of aggregate
aresulting in a new aggregate over a possibly different underlying domain.
- reduce: ((S, R) -> R, A, R) -> R
reduce(f, a, r)applies function
fto each successive element of the aggregate
aand an accumulant initialized to
r. For example,
reduce(_+\$Integer, [1, 2, 3], 0)does
3+(2+(1+0)). Note: third argument
rmay be regarded as the identity element for the function
- scan: ((S, R) -> R, A, R) -> B
scan(f, a, r)successively applies
reduce(f, x, r)to more and more leading sub-aggregates
a. More precisely, if
[a1, a2, ...], then
scan(f, a, r)returns
[reduce(f, [a1], r), reduce(f, [a1, a2], r), ...].