Forum Discussion
LBROWN7
Oct 11, 2023Brass Contributor
Excel Scan versus Reduce LAMBDA Issue
=REDUCE({1}, {2, 3, 4}, LAMBDA(acc, cv, VSTACK(acc, cv))) Works fine in Excel and Google Sheets. =SCAN({1}, {2, 3, 4}, LAMBDA(acc, cv, VSTACK(acc, cv))) generates and Error ...
LBROWN7
Oct 12, 2023Brass Contributor
SergeiBaklan , mtarler - Thanks for your responses.
I do realize that Excel LAMBDA does not support Array of Arrarys, - but I was not trying to do Array or Arrays.
The code works fine when using REDUCE, so I don't think its an Array or Arrays issue.
I often use SCAN to examine the intermediate steps of my REDUCE functions and that is what I was doing here. SCAN and REDUCE should, I would think, be identical in the final output.
My REDUCE function worked fine, so I did not need a workaround.
I will report this as a bug.
Thanks for the input.
I do realize that Excel LAMBDA does not support Array of Arrarys, - but I was not trying to do Array or Arrays.
The code works fine when using REDUCE, so I don't think its an Array or Arrays issue.
I often use SCAN to examine the intermediate steps of my REDUCE functions and that is what I was doing here. SCAN and REDUCE should, I would think, be identical in the final output.
My REDUCE function worked fine, so I did not need a workaround.
I will report this as a bug.
Thanks for the input.
SergeiBaklan
Oct 12, 2023Diamond Contributor
With scan you do array of array. On first step you make array {1;2}, on second step another array {1;2;3} and on on third step one more array {1;2;3;4}. Thus you have 3 arrays which shall be returned as one combined array, i.e. array of array. That doesn't work directly.
With REDUCE on first step you add value to initial array, i.e. generate {1;2}, on each next step you only expand it by another value. Finally you have only one array {1;2;3;4}, single array is returned without any problems.