The SUM Aggregate Function
Currently, the RASON modeling language supports one aggregation statement which may be used to summarize a formula, the sum formula. Similar to for(), sum() is a statement that behaves not as a programming language loop, but rather as an attribute to its assigned formula. The sum() function computes a formula for a given set of indices.
sum(p in 'POT', g in 'GRADE'): {
cost: { formula: "AMT[p, g] * Prem_Cost[g]"}
}
The formula for cost will be computed for each index and the sum of all resultant products will be calculated.
Note: The RASON language sum() statement described above should not be confused with the sum() function that may exist within a formula.
In this example code, AMT is an array, indexed by p and g and Prem_Cost is an array, indexed by g. If AMT[p,g] is a 2x2 matrix
1 1
2 2
and Prem_Cost[g] is a 2 x 1 vertical array
6
9
then PremiumCost will equal 45 (1 * 6 + 1 * 9 + 2 * 6 + 2 * 9).
Back to Advanced Indexed Array Formulas
|