Forum Discussion
data_junky
Feb 21, 2025Copper Contributor
Using Scan function with Oddly shaped arrays
I have two arrays of different shares. One array is a set of values. The other is a set of growth rates. The challenge is to apply the scan function to get the an array of values that are increased...
PeterBartholomew1
Feb 22, 2025Silver Contributor
If it is the ragged array of rates that is important to you, it is possible to select each row as a range object and use TRIMRANGE to reduce it to size.
= LET(
valuesϑ, THUNK(values),
rateϑ, BYROW(rate, LAMBDA(row, THUNK(TRIMRANGE(row)))),
resultϑ, MAP(values, rateϑ, LAMBDA(v,r, THUNK(SCAN(v, 1+r(), PRODUCT)))),
EVALTHUNKARRλ(resultϑ)
)The catch is that the natural stacking of the smaller dimensioned results is to the left of the result array.
Again, this relies upon thunks for referencing arrays of arrays.