Lambdas
Several library methods take a lambda to filter, project, or otherwise refine data. A lambda declares one or more range variables, separated by semicolons, then a colon and a body expression:
@x: @x.price > 10@acc;@current: @acc + @currentA lambda’s variables exist only inside its body.
Example
Section titled “Example”{ "hasValues": "#valueOf($.some.integerArray)->#any(@x: @x > 5)", "filteredData": "#valueOf($.some.complexArray)->#where(@x: @x.some.path < 10)", "projectedData": "#valueOf($.some.complexArray)->#select(@x: @x.some.path)"}{ "some": { "integerArray": [ 1, 2, 6, 10 ], "complexArray": [ { "some": { "path": 5 } }, { "some": { "path": 30 } } ] }}{ "hasValues": true, "filteredData": [ { "some": { "path": 5 } } ], "projectedData": [ 5, 30 ]}Methods that take lambdas
Section titled “Methods that take lambdas”| Arity | Methods |
|---|---|
| One parameter | any, where, select, orderBy, orderByDesc, groupBy, summarizeWith, distinct, takeWhile, skipWhile, max, min, sum, average, try |
| Two parameters | reduce, zip |
Your own C# methods can take lambdas too. See lambdas in external methods.
