Skip to content

Instantly share code, notes, and snippets.

@ncalm
Created April 26, 2024 12:22
Show Gist options
  • Save ncalm/e9c1b7f6ffa5f5ffbf347e956bac4b2e to your computer and use it in GitHub Desktop.
Save ncalm/e9c1b7f6ffa5f5ffbf347e956bac4b2e to your computer and use it in GitHub Desktop.
formula
=LET(
nums, SEQUENCE(10,,,RAND()*10),
data, SCAN(
0,
nums,
LAMBDA(a, v,
LET(
//get the value from the current row of the array
current, INDEX(nums, v, 1),
//get the value from the previous row of the array
previous, INDEX(nums, v - 1, 1),
//if nums-1 is zero, previous is the entire array, so use a default instead
//in this example, I've used zero as the default
previous_adj, IF(ROWS(previous) > 1, 0, previous),
//example calculation involving a, current and previous
a + ABS(current - previous_adj)
)
)
),
data
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment