These docs are for v1.0. Click to read the latest docs for v1.2.

SCAN

Returns an array constructed from each of the results of applying a formula to each element of the array and the previous result.

Syntax

=SCAN(initialValue, array, expression)

Arguments

ArgumentTypeDescription
initialValueAnyInitial value for the previous result
arrayArrayArray of elements
expressionLambdaTransformation to perform on each item of the array

Examples

=SCAN(1, [1, 2, 3], x => x * x.previous)[1, 2, 6]
SCAN formula is called for each item in the array (the values 1, 2, and 3). For each item, the value is multiplied by the previous value, resulting in an array containing the running multiplication: [1, 2, 6].