Forum Discussion
Excel Scan versus Reduce LAMBDA Issue
I don't know but I think they made the conscious decision not to support array of arrays in these functions because of all the potential ways things can go wrong. In your example and many examples there is a clear and correct output:
| 1 | 1 | 1 |
| 2 | 2 | 2 |
| 3 | 3 | |
| 4 |
but if you try this:
=REDUCE(1,hstack( {2;3}, {4;5} ),LAMBDA(acc,cv,VSTACK(acc,cv)))
or in sheets you can go 'more directly' as
=REDUCE(1,{ {2;3}, {4;5} },LAMBDA(acc,cv,VSTACK(acc,cv)))
both result in
1
2
4
3
5
which at least is not the obvious output to me. and neither support SCAN in this case while I would have liked to see
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | |
| 5 |
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.
- SergeiBaklanOct 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.