v.23.10New Feature

Add arrayFold function for multi-array lambda accumulation

Add function arrayFold(accumulator, x1, ..., xn -> expression, initial, array1, ..., arrayn) which applies a lambda function to multiple arrays of the same cardinality and collects the result in an accumulator. #49794 (Lirikl).
Added the arrayFold function which applies a lambda function across multiple arrays of the same length, accumulating results into a single value.

Why it matters

This feature enables users to perform fold (reduce) operations on multiple arrays simultaneously. It solves the problem of aggregating values across several arrays in a single pass, providing more expressive and efficient data transformations.

How to use it

Use arrayFold by passing an accumulator variable, a lambda function describing the folding logic, an initial accumulator value, and one or more arrays of equal cardinality. The syntax is:

arrayFold(accumulator, x1, ..., xn -> expression, initial, array1, ..., arrayn)


where accumulator is the variable holding the folding result, x1, ..., xn are elements of the arrays being folded, and initial is the starting value.