FiniteLinearAggregateFunctions2(S, A, R, B)ΒΆ

aggcat2.spad line 1 [edit on github]

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 f to each member of aggregate a resulting in a new aggregate over a possibly different underlying domain.

reduce: ((S, R) -> R, A, R) -> R

reduce(f, a, r) applies function f to each successive element of the aggregate a and an accumulant initialized to r. For example, reduce(_+\$Integer, [1, 2, 3], 0) does 3+(2+(1+0)). Note: third argument r may be regarded as the identity element for the function f.

scan: ((S, R) -> R, A, R) -> B

scan(f, a, r) successively applies reduce(f, x, r) to more and more leading sub-aggregates x of aggregrate a. More precisely, if a is [a1, a2, ...], then scan(f, a, r) returns [reduce(f, [a1], r), reduce(f, [a1, a2], r), ...].