back

by layer8·5y ago·view on hn ↗
The following bit from the documentation [0] ("step 2") is a bit strange:

> A good practice is to create and test your LAMBDA function in a cell to make sure it works correctly, including the definition and the passing of parameters. To avoid the #CALC! error, add a call to the LAMBDA function to immediately return the result:

> =LAMBDA function ([parameter1, parameter2, ...],calculation) (function call)

> The following example returns a value of 2.

> =LAMBDA(number, number + 1)(1)

> Assuming the LAMBDA function is in cell A1, you can reference the cell that contains the LAMBDA function in the following way:

> =A1(1)

What this seems to say is that (1) you get a #CALC! error when a cell contains a bare =LAMBDA(...) expression, and (2) if the lambda calls itself (doesn't produce a #CALC! error any more), then you can call it with a different argument by referencing the cell containing the self-invocation (the "=A1(1)" example above). This seems like a weird model, because just "=A1" would give you the result of the self-invocation.

Maybe the documentation intends to say that you can do the "=A1(1)" call iff the cell containing the lambda is not a self-invocation (but then shows the #CALC! error)?

[0] https://support.microsoft.com/en-us/office/lambda-function-b...

1 comments
(1) is explicitly spelled out:

> If you create a LAMBDA function in a cell without also calling it from within the cell, Excel returns a #CALC! error.

For (2), I think what they're saying is that if you need to test the function with different arguments, for example, it may be more convenient to reference the cell with the lambda.