Forum Discussion
MAP x MAP
- Mar 31, 2023
Why don't you post something closer to your actual problem? I am sure we can help and so, save you some pain! For example, YEARFRAC tends to play better if you put a + sign in front of multi-cell range references to convert them to arrays. If you are trying to return the results in a 2D grid, MAP has an annoying flaw in that it will not return a nested array / array-of-arrays (i.e. the correct answer to your problem). Workarounds include MAKEARRAY and REDUCE combined with VSTACK.
Sadly, no simple tricks. The nearest for MAX(a, b) is
= IF(a>b, a, b)
which will broadcast to give a 2D array of results.
Otherwise one could write a Lambda function XMAP to generalise MAP to broadcast the two parameters to give a 2D array, which will then be processed by the inbuilt MAP function.
XMAP(x, y, Fnλ)
= MAP(Broadcastλ(x, y), Broadcastλ(y, x), Fnλ)
Broadcastλ(x, y)
= IF(SIGN(y), x)
Maxλ(x, y)
= MAX(x, y)
Minλ(x, y)
= MIN(x, y)
The worksheet formulae would then be
= XMAP(date, period, Maxλ)
= XMAP(date, period, Minλ)
Hey ho. It is what it is. And your suggestion works. So I settle for that. Thanks.