Skip to main content

Reduce

This formula allows you to reduce an array (list) of values into a single value. A typical use case for this formula is to sum all the numbers in an array:

{
"type": "reduce",
"components": {
"type": "stat",
"stat": "a_stat_with_a_list_of_numbers"
},
"reducer": {
"type": "add",
"components": {
"type": "list",
"components": [
{
"type": "stat",
"stat": "$reduceAccumulator"
},
{
"type": "stat",
"stat": "$reduceValue"
}
]
}
}
}

Returns

S

JSON Format

{
"type": "reduce",
"components": ...,
"reducer": ...,
"reduce_accumulator_key": ...,
"reduce_value_key": ...
}

RPG Script

This component can be written in RPG Script as:

reduce(...)

Fields

FieldTypeRequiredDescription
reduce_value_keyStringOptional parameter that lets you provide a key to use in the reducer formula to access the array's current value in the iteration. e.g: if you are iterating classes, you might want to assign "$class" to the reduce_value_key, to make your system easier to read. This is also helpful when dealing with nested Reduce formulas, as it will allow inner Reduce formulas to access the values of outer filter formulas.