# LAMBDA

Spread for WinForms provides advanced software components that support Excel import/export, full cell customization, an extensive calculation engine with over 450 functions and more, all with zero dependencies on Excel.

## Content



This function can be used to create custom, reusable functions and call them by a desired name. You can create functions for commonly used formulas and effectively add your own functions.

## Syntax

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

## Argument

This function has the following 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 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
* It is not advisable to use a period (.) in a parameter name

## 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 sample code show the basic usage of LAMBDA function.

```JavaScript
IWorkbook workbook = fpSpread1.AsWorkbook();
workbook.Names.Add("HEAD", "LAMBDA(str, IF(str=\"\",\"error: HEAD of empty string\",LEFT(str,1)))");
workbook.Names.Add("TAIL", "LAMBDA(str, IF(str=\"\",\"error: TAIL of empty string\",RIGHT(str,LEN(str)-1)))");
workbook.Names.Add("REVERSE", "LAMBDA(str,IF(str=\"\",\"\",REVERSE(TAIL(str))&HEAD(str)))");
IWorksheet sheet1 = workbook.Worksheets[0];
sheet1.Cells["A1"].Value = 12345;
sheet1.Cells["B1"].Formula2 = "HEAD(A1)";
sheet1.Cells["C1"].Formula2 = "TAIL(A1)";
sheet1.Cells["D1"].Formula2 = "REVERSE(A1)";
sheet1.Cells["B2:D2"].Formula2 = "FORMULATEXT(B1)";
 
sheet1.Cells["F1"].Formula2 = "LAMBDA(x, x+122)(1)";
```

The output of above code will look like below:
![](https://cdn.mescius.io/document-site-files/images/0ed25d3e-6b2a-4cf0-8f1b-7ed5ab18cf12/images/lambdafunction.png)

## Version Available

This function is available in product version 15 or later.

## Lambda Helper Functions

Spread also supports seven new LAMBDA helper functions. These functions help in the authoring of re-usable LAMBDA functions and also serve as stand-alone functions themselves. For more information, refer:

1. [BYROW](/spreadnet/docs/latest/online-formula/formulas-functionsall/formulas-functsAtoC/functionByrow)
2. [BYCOL](/spreadnet/docs/latest/online-formula/formulas-functionsall/formulas-functsAtoC/functionBycol)
3. [ISOMITTED](/spreadnet/docs/latest/online-formula/formulas-functionsall/formulas-functsFtoK/functionIsomitted)
4. [MAKEARRAY](/spreadnet/docs/latest/online-formula/formulas-functionsall/formulas-functsMtoQ/functionMakearray)
5. [MAP](/spreadnet/docs/latest/online-formula/formulas-functionsall/formulas-functsMtoQ/functionMap)
6. [REDUCE](/spreadnet/docs/latest/online-formula/formulas-functionsall/formulas-functsRtoS/functionReduce)
7. [SCAN](/spreadnet/docs/latest/online-formula/formulas-functionsall/formulas-functsRtoS/functionScan)