Array-reducing functions
An array-reducing function operates across a dimension of an array and returns a result that has one dimension less than the number of dimensions of its input array. When applied to an array of n
dimensions, a reducing function produces an array that contains n-1
dimensions. Examples include, Sum(x, i), Product(x,i), Max(x, i), Min(x, i), and others described below. The subscript construct x[i = v] and related subscript and slice functions also reduce arrays by a dimension (see Subscript and slice of a subarray).
The function Sum(x, i) illustrates some properties of reducing functions.
Examples
Sum(Car_prices, Car_type) →
Years ▶ | ||||
---|---|---|---|---|
2005 | 2006 | 2007 | 2008 | 2009 |
59K | 62K | 66K | 71K | 76K |
Sum(Car_prices, Years) →
Car_type ▶ | ||
---|---|---|
VW | Honda | BMW |
99K | 103K | 141K |
Sum(Sum(Car_prices, Years), Car_type) → 334K
See Array Function Example Variables for example array variables used here and below.
Enable comment auto-refresher