Xlambda
Well-known Member
- Joined
- Mar 8, 2021
- Messages
- 860
- Office Version
- 365
- Platform
- Windows
T_APPNAR tool formula, a LAMBDA that writes other explicit LAMBDA for appending N arrays horizontally of vertically.
If the arrays we need to append are in different spreadsheets or are created inside other formulas, we can not use recursion to ease our task , we have to construct explicit formulas that fits particular scenarios.
Ex: Formula for appending 6 arrays vertically , we call T_APPNAR(6,"v")=LAMBDA(a1r,a2r,a3r,a4r,a5r,a6r,APPEND2V(APPEND2V(APPEND2V(APPEND2V(APPEND2V(a1r,a2r,),a3r,),a4r,),a5r,),a6r,))
OBS: You need to have already defined APPEND2V and APPEND2H, then you can define like APPEND6V(a1r,a2r,a3r,a4r,a5r,a6r) and reuse it any time you need it.
Note: personal syntax T_, comes from tool, means that are formulas instruments used for helping us on solving bigger picture tasks, like to write other formulas, patterns transformations, interfaces to ease complex conditional formatting formulas etc.
If the arrays we need to append are in different spreadsheets or are created inside other formulas, we can not use recursion to ease our task , we have to construct explicit formulas that fits particular scenarios.
Ex: Formula for appending 6 arrays vertically , we call T_APPNAR(6,"v")=LAMBDA(a1r,a2r,a3r,a4r,a5r,a6r,APPEND2V(APPEND2V(APPEND2V(APPEND2V(APPEND2V(a1r,a2r,),a3r,),a4r,),a5r,),a6r,))
OBS: You need to have already defined APPEND2V and APPEND2H, then you can define like APPEND6V(a1r,a2r,a3r,a4r,a5r,a6r) and reuse it any time you need it.
Note: personal syntax T_, comes from tool, means that are formulas instruments used for helping us on solving bigger picture tasks, like to write other formulas, patterns transformations, interfaces to ease complex conditional formatting formulas etc.
Excel Formula:
=LAMBDA(na,hv,
LET(x,OR(hv={"h","v"}),
a,"=LAMBDA(",b,REPT("a"&SEQUENCE(,na)&"r,",1),
c,REPT("APPEND2"&UPPER(hv)&"(",SEQUENCE(,na-1,1,0)),
d,"a1r",e,","&REPT("a"&SEQUENCE(,na-1,2)&"r,)",1),f,")",
IF(x,CONCAT(a,b,c,d,e,f),"''h''or''v''only")
)
)
LAMBDA 5.0.xlsm | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | |||
1 | a1 - 1 | a1 - 2 | a2 - 1 | a2 - 2 | a4 - 1 | a4 - 2 | |||||
2 | a1 - 3 | a1 - 4 | a2 - 3 | a2 - 4 | a4 - 3 | a4 - 4 | |||||
3 | a1 - 5 | a1 - 6 | a2 - 5 | a2 - 6 | a4 - 5 | a4 - 6 | |||||
4 | a1 - 7 | a1 - 8 | a2 - 7 | a2 - 8 | a4 - 7 | a4 - 8 | |||||
5 | a1 - 9 | a1 - 10 | a2 - 9 | a2 - 10 | |||||||
6 | a1 - 11 | a1 - 12 | a2 - 11 | a2 - 12 | a5 - 1 | a5 - 2 | |||||
7 | a1 - 13 | a1 - 14 | a5 - 3 | a5 - 4 | |||||||
8 | a1 - 15 | a1 - 16 | a3 - 1 | a3 - 2 | a5 - 5 | a5 - 6 | |||||
9 | a1 - 17 | a1 - 18 | a3 - 3 | a3 - 4 | a5 - 7 | a5 - 8 | |||||
10 | a1 - 19 | a1 - 20 | a3 - 5 | a3 - 6 | |||||||
11 | a1 - 21 | a1 - 22 | a3 - 7 | a3 - 8 | a6 - 1 | a6 - 2 | |||||
12 | a1 - 23 | a1 - 24 | a3 - 9 | a3 - 10 | a6 - 3 | a6 - 4 | |||||
13 | a3 - 11 | a3 - 12 | a6 - 5 | a6 - 6 | |||||||
14 | a6 - 7 | a6 - 8 | |||||||||
15 | ex: append the arrays above all toghether,considering that are not in the same spreadsheet or are results of other array calculations | ||||||||||
16 | that live inside a formula (we can not use APPENDNHV) | ||||||||||
17 | |||||||||||
18 | get to a cell, call =T_APPNAR(3,"v"), the formula shows the string result =LAMBDA(a1r,a2r,a3r,APPEND2V(APPEND2V(a1r,a2r,),a3r,)) , copy the cell, paste in other cell as value, hit the F2, or click the cursor inside the cell, hit Enter, we will get a #CALC! error. Then, from the formula bar, copy the whole formula, hit escape, go to name manager , define APPEND3V, and thats it.Follow the same steps for APPEND3H. Now we can use them. | ||||||||||
19 | |||||||||||
20 | =T_APPNAR(3,"v") | =T_APPNAR(3,"h") | |||||||||
21 | =LAMBDA(a1r,a2r,a3r,APPEND2V(APPEND2V(a1r,a2r,),a3r,)) | =LAMBDA(a1r,a2r,a3r,APPEND2H(APPEND2H(a1r,a2r,),a3r,)) | |||||||||
22 | |||||||||||
23 | =LAMBDA(a1r,a2r,a3r,APPEND2V(APPEND2V(a1r,a2r,),a3r,)) | =LAMBDA(a1r,a2r,a3r,APPEND2H(APPEND2H(a1r,a2r,),a3r,)) | |||||||||
24 | #CALC! | #CALC! | |||||||||
25 | |||||||||||
26 | =APPEND3H(A1#,APPEND2V(D1#,D8#,),APPEND3V(G1#,G6#,G11#)) | ||||||||||
27 | a1 - 1 | a1 - 2 | a2 - 1 | a2 - 2 | a4 - 1 | a4 - 2 | |||||
28 | a1 - 3 | a1 - 4 | a2 - 3 | a2 - 4 | a4 - 3 | a4 - 4 | |||||
29 | a1 - 5 | a1 - 6 | a2 - 5 | a2 - 6 | a4 - 5 | a4 - 6 | |||||
30 | a1 - 7 | a1 - 8 | a2 - 7 | a2 - 8 | a4 - 7 | a4 - 8 | |||||
31 | a1 - 9 | a1 - 10 | a2 - 9 | a2 - 10 | a5 - 1 | a5 - 2 | |||||
32 | a1 - 11 | a1 - 12 | a2 - 11 | a2 - 12 | a5 - 3 | a5 - 4 | |||||
33 | a1 - 13 | a1 - 14 | a3 - 1 | a3 - 2 | a5 - 5 | a5 - 6 | |||||
34 | a1 - 15 | a1 - 16 | a3 - 3 | a3 - 4 | a5 - 7 | a5 - 8 | |||||
35 | a1 - 17 | a1 - 18 | a3 - 5 | a3 - 6 | a6 - 1 | a6 - 2 | |||||
36 | a1 - 19 | a1 - 20 | a3 - 7 | a3 - 8 | a6 - 3 | a6 - 4 | |||||
37 | a1 - 21 | a1 - 22 | a3 - 9 | a3 - 10 | a6 - 5 | a6 - 6 | |||||
38 | a1 - 23 | a1 - 24 | a3 - 11 | a3 - 12 | a6 - 7 | a6 - 8 | |||||
39 | |||||||||||
40 | OBS: Both APPEND2V and ..2H need to have the trailing "," , the ..3V or ..3H don't need them | ||||||||||
41 | NOTE: If you use this pattern extensivly it can be save as a LAMBDA also, especially for whatever pattern suits you nneds | ||||||||||
42 | |||||||||||
T_APPNAR post |
Cell Formulas | ||
---|---|---|
Range | Formula | |
A1:B12 | A1 | ="a1 - "&SEQUENCE(12,2) |
D1:E6 | D1 | ="a2 - "&SEQUENCE(6,2) |
G1:H4 | G1 | ="a4 - "&SEQUENCE(4,2) |
G6:H9 | G6 | ="a5 - "&SEQUENCE(4,2) |
D8:E13 | D8 | ="a3 - "&SEQUENCE(6,2) |
G11:H14 | G11 | ="a6 - "&SEQUENCE(4,2) |
A20,A26,A23,E23,E20 | A20 | =FORMULATEXT(A21) |
A21 | A21 | =T_APPNAR(3,"v") |
E21 | E21 | =T_APPNAR(3,"h") |
A24 | A24 | =LAMBDA(a1r,a2r,a3r,APPEND2V(APPEND2V(a1r,a2r,),a3r,)) |
E24 | E24 | =LAMBDA(a1r,a2r,a3r,APPEND2H(APPEND2H(a1r,a2r,),a3r,)) |
A27:F38 | A27 | =APPEND3H(A1#,APPEND2V(D1#,D8#,),APPEND3V(G1#,G6#,G11#)) |
Dynamic array formulas. |
Upvote
0