# LAMBDA

## Content

This function allows you to create and name custom reusable functions that can be called like any other function.

## Syntax

`=LAMBDA([parameter1, parameter2, …,], calculation)`

## Arguments

This function has these arguments:

| Argument | Description |
| -------- | ----------- |
| *parameter* | [Optional] A value that you want to pass to the function, such as a cell reference, string or number. You can enter up to 253 parameters. |
| *calculation* | [Required] The formula you want to execute and return as the result of the function. It must be the last argument and it must return a result. |

## Remarks

* If an incorrect number of parameters or more than 253 parameters are provided to a LAMBDA function, it returns a #VALUE! error.
* If an incorrect number of arguments is passed to a LAMBDA function, it returns a #VALUE! error.
* If you call a LAMBDA function from within itself and the call is circular, it returns a #NUM! error.
* If you create a LAMBDA function in a cell without also calling it from within the cell, it returns a #CALC! error.

> **Note:** If the lambda function is recursive, the maximum recursion depth is related to the browser.

## Data Types

The concise format returns a text value, whereas the strict format returns an array of the same size and shape as the input.

## Examples

The following code sample shows the basic usage of LAMBDA function.

```JavaScript
//basic usage of LAMBDA function using one parameter
sheet.setValue(1, 1, "Converted Temp");
spread.addCustomName('ToCelsius', 'LAMBDA(temp, (5/9) * (temp-32))');
sheet.setFormula(2, 1, 'ToCelsius(104)'); // result is 40
            
//basic usage of LAMBDA function using two parameters
sheet.setValue(1, 3, "Calculated Hypotenuse");
spread.addCustomName('Hypotenuse', 'LAMBDA(a, b, SQRT((a^2+b^2)))');
sheet.setFormula(2, 3, 'Hypotenuse(3, 4)'); // result is 5
```

The below output will be generated:
![image.png](https://gcdocumentsitekrblob.blob.core.windows.net/document-site-files/images/8d606653-16a0-474d-b9dc-e2b4d01c2446/image.2e12ee.png)

### Lambda Helper Functions

SpreadJS supports seven new LAMBDA helper functions. These functions help creating re-usable LAMBDA functions by having LAMBDA function as a parameter. They also serve as stand-alone functions themselves. For more information, refer:

1. [BYROW](/spreadjs/docs/v17/formulareference/FormulaFunctions/other-functions/byrow-function)
2. [BYCOL](/spreadjs/docs/v17/formulareference/FormulaFunctions/other-functions/bycol-function)
3. [ISOMITTED](/spreadjs/docs/v17/formulareference/FormulaFunctions/other-functions/isomitted-function)
4. [MAKEARRAY](/spreadjs/docs/v17/formulareference/FormulaFunctions/other-functions/makearray-function)
5. [MAP](/spreadjs/docs/v17/formulareference/FormulaFunctions/other-functions/map-function)
6. [REDUCE](/spreadjs/docs/v17/formulareference/FormulaFunctions/other-functions/reduce-function)
7. [SCAN](/spreadjs/docs/v17/formulareference/FormulaFunctions/other-functions/scan-function)