Forum Discussion
A LAMBDA Exercise
Essentially, I was working on a solution where I had created an array and then needed to check each element in the array to determine if it would be a 1 or 0. I was using MAP with a dummy range of identical dimensions to obtain Row and Column. The problem was getting the array to know when to stop filling in 1s.
For example. Item 1 shows 3. By the time I get to the 4th position in the array, I need to tell it to stop filling in 1s even though it's still concerned with Item 1.
I hope that makes sense. I may revisit de-stacking with a clearer head.
I am not sure I fully understand the scenario and, it may well be that I am simply agreeing with Matt. That said, I see that helper functions like MAP and SCAN may perform calculations element by element without there being an obvious means of addressing adjacent elements of the array. In such a situation, my suggestion would be to scan an index array rather than directly scanning the target array. Elements of the target array could then be returned by use of the INDEX function, e.g.
= MAP(indexArray,
LAMBDA(k,
AVERAGE(
INDEX( targetArray, k+{0,1,2} )
)
)
)
Am I on the right track?
- Patrick2788Jul 01, 2022Silver Contributor
Yes, I think you and mtarler have it correct. I have a way (SCAN with XLOOKUP using SEQUENCE for lookup array and return array) to reset sequential numbering (e.g 1,2,3,4,5,6,1,2,3, etc) but I don't believe it can be scaled for large data sets.
I still need to study your workbook from the destacking thread. When I'm at my desk at work I don't have access to an Insider build so I'm missing out during typical working hours!