FlatMap
This formula is like the Map formula. However, it will also flatten the
resulting list values into one. i.e: If the mapping returns three lists of
numbers, this formula will return one list flat-appending (see FlatAppend)
the three lists.
JSON Format
{
"type": "flatMap",
"components": ...,
"mapper": ...,
"map_value_key": ...
}
Fields
| Field | Type | Required | Description |
|---|---|---|---|
components | StatFormulaComponent | ✓ | The formula for the array (list) of elements you want to map. |
mapper | StatFormulaComponent | ✓ | The formula for the mapping to perform on each element of the given components list. Anything inside this formula can make use of the $mapValue stat, which will contain the current value for the iteration (e.g: if iterating the array ['a', 'b', 'c'], $mapValue will first be equal to 'a', then 'b' and then 'c'), thus allowing the formula specified here to access the value of each element in the array one at a time as part of the mapper. If you were to specify the optional map_value_key parameter, you should use the key given there instead of $mapValue to access these values. |
map_value_key | String | Optional parameter that lets you provide a key to use in the mapper 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 map_value_key, to make your system easier to read. This is also helpful when dealing with nested FlatMap formulas, as it will allow inner FlatMap formulas to access the values of outer filter formulas. |