reduce
reduce a container with a function
Calling Sequence
Parameters
Description
Thread Safety
Examples
Compatibility
reduce(fcn, expr)
reduce[evalhf](fcn, expr)
reduce[scan](fcn, expr)
reduce[inplace](fcn, expr)
reduce[dimension=n](fcn, expr)
fcn
-
expression of type appliable; typically, a procedure or name
expr
any expression
The reduce function applies the reduction operation specified by fcn to the operands or elements of expr.
Some options can be specified in square brackets as an index to the reduce function. These options can be used by themselves or in combination with other options.
When reducing over an rtable (Array, Vector, or Matrix), if the evalhf option is passed, each evaluation of fcn is evaluated using evalhf.
If the scan option is passed, the reduction is performed cumulatively on the elements of expr, producing a result with the same dimensions as expr.
When expr is an rtable, the inplace option can be used in conjunction with the scan option to compute the result in-place in expr.
The dimension option (alternately axis) restricts the reduction along one dimension of an rtable, producing a result with one less dimension than expr.
The inplace and evalhf options are currently ignored if the dimension option is used.
The reduce function is thread safe, provided that evaluating fcn is thread safe.
For more information on thread safety, see index/threadsafe.
reduce⁡`+`,1,2,3,4,5
15
reducescan⁡`+`,1,2,3,4,5
1,3,6,10,15
reduce⁡`+`,1|2,3|4
10
reducedimension=1⁡`+`,a|b,c|d
a+cb+d
reducedimension=2⁡`+`,a|b,c|d
a+bc+d
reducedimension=1,scan⁡`+`,a|b,c|d
aba+cb+d
reducedimension=2,scan⁡`+`,a|b,c|d
aa+bcc+d
The reduce command was introduced in Maple 2021.
For more information on Maple 2021 changes, see Updates in Maple 2021.
See Also
ArrayTools[ReduceAlongDimension]
ArrayTools[ScanAlongDimension]
map
Download Help Document