Forum Discussion
A statement of truth or a wasted opportunity. Lambda helper functions reluctant to return 2D arrays.
What I wanted to achieve was an array of two SCANs, one down each of two columns, with a row of two initial values, so that I could compare the effect of 10% depreciation against 20%. I had picked up the message that arrays of arrays were not allowed, so expected an error message. The surprise was that I got numbers at all, then that I couldn't immediately recognise the values returned.
I have used MAP to return each of a 2D array as independent calculations, but order hardly matters there. What I hadn't realised was that SCAN and REDUCE would also accept 2D arrays in exactly the same way but, given they are accumulating, order is important. It seems to work like the Persian story of one grain of rice being placed on the first square of a chess board and two on the next. 2⁶⁴ grains are unaffordable. The modern-day equivalent might be 'on the second week there will be two Covid cases'. Some of our politicians were noticeably unable to grasp the consequences.
Thanks, my reading comprehension seems to be off the past day or two.
In trying to work through other routes for this problem, I made a further connection that seems obvious after typing it out: MAKEARRAY(rows_,cols_,LAMBDA(i,j,...)) is just a special case of MAP(array_1,array_2,LAMBDA(a_1,a_2,...)). I assume MAKEARRAY just does the handling of ensuring array_1 and array_2 have the same dimensions and values are all TYPE=1.