Xlambda
Well-known Member
- Joined
- Mar 8, 2021
- Messages
- 860
- Office Version
- 365
- Platform
- Windows
AMIN,AMAX !! recursive !! array min, array max, calculates MIN or MAX for each row of an array, calls APPEND2V
Important NOTE: all my recursive function can be written also non recursive. So far, lambda being in beta, has a limited nr. of iterations, (200 to 300) (has nothing to do with nr. of iterations found under Options Formulas). When a recursive formula excedes the nr. of iterations will get the #NUM error. I choose the recursive path for any formula possible, apart for being short simple and elegant, to help anybody who wants, to get familiarized with the concept.
AMIN:
AMAX:
Important NOTE: all my recursive function can be written also non recursive. So far, lambda being in beta, has a limited nr. of iterations, (200 to 300) (has nothing to do with nr. of iterations found under Options Formulas). When a recursive formula excedes the nr. of iterations will get the #NUM error. I choose the recursive path for any formula possible, apart for being short simple and elegant, to help anybody who wants, to get familiarized with the concept.
AMIN:
Excel Formula:
=LAMBDA(ar,ns,
LET(s,--ns,n,ROWS(ar),c,COLUMNS(ar),x,MIN(INDEX(ar,n,)),
IF(n=1,INDEX(APPEND2V(x,s,),SEQUENCE(ROWS(s))),AMIN(INDEX(ar,SEQUENCE(n-1),SEQUENCE(,c)),APPEND2V(x,s,)))
)
)
Excel Formula:
=LAMBDA(ar,ns,
LET(s,--ns,n,ROWS(ar),c,COLUMNS(ar),x,MAX(INDEX(ar,n,)),
IF(n=1,INDEX(APPEND2V(x,s,),SEQUENCE(ROWS(s))),AMAX(INDEX(ar,SEQUENCE(n-1),SEQUENCE(,c)),APPEND2V(x,s,)))
)
)
LAMBDA 6.0.xlsx | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | sample | =AMIN(A2:F5,) | check | =AMAX(A2:F5,) | check | |||||||||
2 | 25 | -2 | -93 | 0 | 17 | 31 | -93 | -93 | 31 | 31 | ||||
3 | -86 | 6 | 39 | 88 | -11 | -85 | -86 | -86 | 88 | 88 | ||||
4 | 67 | 56 | -86 | -30 | 42 | -77 | -86 | -86 | 67 | 67 | ||||
5 | -59 | 20 | 32 | -15 | -45 | -77 | -77 | -77 | 32 | 32 | ||||
6 | ||||||||||||||
7 | text,blanks,logical, ignored like main MIN and MAX work in Excel | =AMIN(A8:F11,) | check | =AMAX(A8:F11,) | check | |||||||||
8 | text | -2 | 0 | 2 | b | -2 | -2 | 2 | 2 | |||||
9 | -3 | FALSE | TRUE | 3 | text | -3 | -3 | 3 | 3 | |||||
10 | a | b | c | d | e | f | 0 | 0 | 0 | 0 | ||||
11 | TRUE | TRUE | FALSE | FALSE | TRUE | FALSE | 0 | 0 | 0 | 0 | ||||
12 | ||||||||||||||
AMIN,AMAX post |
Cell Formulas | ||
---|---|---|
Range | Formula | |
H1,J7,H7,J1 | H1 | =FORMULATEXT(H2) |
H2:H5,H8:H11 | H2 | =AMIN(A2:F5,) |
J2:J5,J8:J11 | J2 | =AMAX(A2:F5,) |
I2:I5,I8:I11 | I2 | =MIN(A2:F2) |
K2:K5,K8:K11 | K2 | =MAX(A2:F2) |
Dynamic array formulas. |
Last edited by a moderator:
Upvote
0