Excel's LAMBDA with a "kind of" composite function
Excel's LAMBDA with a "kind of" composite function
Excel's LAMBDA with a "kind of" composite function
Re: Excel's LAMBDA with a "kind of" composite function
Very nice question.
I noticed that in your attempts you have given [`REDUCE()`](https://support.microsoft.com/en-us/office/reduce-function-42e39910-b345-45f3-84b8-0642b568b7cb) a *single* constant value in the 1st parameter. Funny enough, the documentation nowhere states you can't give values in *array-format*. Hence you could use the 1st parameter to give all the constants in (your case; horizontal) array-format, and while you loop through the array of the 2nd parameter you can apply the different types of logic using `CHOOSE()`:
[](https://i.sstatic.net/SLHE5.png)
```
=REDUCE({0,1},SEQUENCE(5),LAMBDA(a,b,CHOOSE({1,2},a+b,a*b)))
```
This way you have a single `REDUCE()` function which internal processes will update the given constants from the 1st parameter in array-form. You can now start stacking multiple functions horizontally and input an array of constants, for example:
```
=REDUCE({0,1,100},SEQUENCE(5),LAMBDA(a,b,CHOOSE({1,2,3},a+b,a*b,a/b)))
```
I suppose you'd have to use `{0\1}` and `{1\2}` like I'd have to in my Dutch version of Excel.
Given your accumulator:
[](https://i.sstatic.net/Ns2tf.png)
Formula in `A1`:
```
=REDUCE(F1:G1,SEQUENCE(F3),LAMBDA(a,b,CHOOSE({1,2},a+b,a*b)))
```
I noticed that in your attempts you have given [`REDUCE()`](https://support.microsoft.com/en-us/office/reduce-function-42e39910-b345-45f3-84b8-0642b568b7cb) a *single* constant value in the 1st parameter. Funny enough, the documentation nowhere states you can't give values in *array-format*. Hence you could use the 1st parameter to give all the constants in (your case; horizontal) array-format, and while you loop through the array of the 2nd parameter you can apply the different types of logic using `CHOOSE()`:
[](https://i.sstatic.net/SLHE5.png)
```
=REDUCE({0,1},SEQUENCE(5),LAMBDA(a,b,CHOOSE({1,2},a+b,a*b)))
```
This way you have a single `REDUCE()` function which internal processes will update the given constants from the 1st parameter in array-form. You can now start stacking multiple functions horizontally and input an array of constants, for example:
```
=REDUCE({0,1,100},SEQUENCE(5),LAMBDA(a,b,CHOOSE({1,2,3},a+b,a*b,a/b)))
```
I suppose you'd have to use `{0\1}` and `{1\2}` like I'd have to in my Dutch version of Excel.
Given your accumulator:
[](https://i.sstatic.net/Ns2tf.png)
Formula in `A1`:
```
=REDUCE(F1:G1,SEQUENCE(F3),LAMBDA(a,b,CHOOSE({1,2},a+b,a*b)))
```