Link to Wikipedia on thunks
Some LAMBDA helpers have limitations on what can be returned due to constraints based on the shape of the starting array. For example, if some calculation creates a series of 2-d arrays, Excel will throw an error if we try to pass those back through SCAN/BYROW/BYCOL. Thunking a value by wrapping it in a LAMBDA with no parameter "stores" a complex value in a single cell in an array, which can be passed around in calculations; we trade error-handling constructions for thunking.
I'll add some helper functions for use with thunks soon.
Excel Formula:
=LAMBDA(x,LAMBDA(x))
Some LAMBDA helpers have limitations on what can be returned due to constraints based on the shape of the starting array. For example, if some calculation creates a series of 2-d arrays, Excel will throw an error if we try to pass those back through SCAN/BYROW/BYCOL. Thunking a value by wrapping it in a LAMBDA with no parameter "stores" a complex value in a single cell in an array, which can be passed around in calculations; we trade error-handling constructions for thunking.
I'll add some helper functions for use with thunks soon.
LAMBDA_pairwise_thunks_summarize_pivot.xlsx | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | |||||||||
2 | =LAMBDA(x,LAMBDA(x))("anything") | #CALC! | |||||||
3 | =LAMBDA(x,LAMBDA(x))("anything")() | anything | |||||||
4 | |||||||||
5 | =LET( thunkIt,LAMBDA(x,LAMBDA(x)), thunkIt(10) ) | #CALC! | |||||||
6 | |||||||||
7 | |||||||||
8 | |||||||||
9 | =thunkIt(10)() | 10 | |||||||
10 | |||||||||
11 | =thunkIt(SEQUENCE(4,4)) | #CALC! | |||||||
12 | =thunkIt(SEQUENCE(4,4))() | 1 | 2 | 3 | 4 | ||||
13 | 5 | 6 | 7 | 8 | |||||
14 | 9 | 10 | 11 | 12 | |||||
15 | 13 | 14 | 15 | 16 | |||||
16 | |||||||||
17 | =MAP(SEQUENCE(4), LAMBDA(num,CHAR(SEQUENCE(num,num,65,1)))) | #CALC! | |||||||
18 | |||||||||
19 | |||||||||
20 | =LET( thunks, MAP(SEQUENCE(4), LAMBDA(num, thunkIt(CHAR(SEQUENCE(num,num,65,1))))), REDUCE(,thunks, LAMBDA(stacked,thunk, vStack(IFERROR(stacked(),stacked),thunk()))) ) | A | |||||||
21 | A | B | |||||||
22 | C | D | |||||||
23 | A | B | C | ||||||
24 | D | E | F | ||||||
25 | G | H | I | ||||||
26 | A | B | C | D | |||||
27 | E | F | G | H | |||||
28 | I | J | K | L | |||||
29 | M | N | O | P | |||||
thunkIt |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2:B3,B20,B17,B11:B12,B9,B5 | B2 | =FORMULATEXT(C2) |
C2 | C2 | =LAMBDA(x,LAMBDA(x))("anything") |
C3 | C3 | =LAMBDA(x,LAMBDA(x))("anything")() |
C5 | C5 | =LET( thunkIt,LAMBDA(x,LAMBDA(x)), thunkIt(10) ) |
C9 | C9 | =thunkIt(10)() |
C11 | C11 | =thunkIt(SEQUENCE(4,4)) |
C12:F15 | C12 | =thunkIt(SEQUENCE(4,4))() |
C17 | C17 | =MAP(SEQUENCE(4), LAMBDA(num,CHAR(SEQUENCE(num,num,65,1)))) |
C20:F29 | C20 | =LET( thunks, MAP(SEQUENCE(4), LAMBDA(num, thunkIt(CHAR(SEQUENCE(num,num,65,1))))), REDUCE(,thunks, LAMBDA(stacked,thunk, vStack(IFERROR(stacked(),stacked),thunk()))) ) |
Dynamic array formulas. |
Upvote
0