Using REDUCE makes it easy to recursively compose a LAMBDA with itself.
Excel Formula:
=LAMBDA(fn,n,
REDUCE(
fn,
SEQUENCE(n-1),
LAMBDA(composed,ignored,
LAMBDA(x,composed(fn(x)))
)
)
)
LAMBDA_COMPOSE.xlsx | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | Value | n | APPLYN | |||
2 | 1 | 10 | 11 | |||
3 | 1 | 100 | 101 | |||
4 | 1 | 510 | 511 | |||
5 | 1 | 511 | #NUM! | <-Recursion depth limits still in place | ||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
C2:C5 | C2 | =APPLYN(LAMBDA(x,x+1),B2)(A2) |
Upvote
0