groimp-platform:xl-lambda
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
groimp-platform:xl-lambda [2025/01/23 15:59] – Tim | groimp-platform:xl-lambda [2025/01/24 08:12] (current) – [In-line Lambda functions] Tim | ||
---|---|---|---|
Line 74: | Line 74: | ||
</ | </ | ||
+ | |||
+ | ===== In-line Lambda functions ===== | ||
+ | |||
+ | |||
+ | In RGG, for Java as well as XL blocks it is possible to combine several expressions in one expression, using brackets and separating them by comma. The expressions will then be executed in order from left to right, and the last one on the right defines the return value of the surrounding lambda expression. | ||
+ | |||
+ | An expression can be almost any feature of RGG: | ||
+ | * Variable declaration | ||
+ | * Variable assignment/ | ||
+ | * XL context query | ||
+ | * Java/RGG functions | ||
+ | * Ternary conditional operator | ||
+ | |||
+ | ==== Variable handling ==== | ||
+ | |||
+ | A simple example for a in-line lambda is the combination of several mathematical steps in one expression would be the following, which sets the value if a to 6. | ||
+ | <code java> | ||
+ | int a = (int i=1, | ||
+ | </ | ||
+ | The variable i stays in the scope of the lambda expression and can be used by the two following expressions but not outside of the brackets. | ||
+ | |||
+ | ==== XL Context queries ==== | ||
+ | |||
+ | XL context queries e.g. '' | ||
+ | |||
+ | For example '' | ||
+ | |||
+ | It is also possible to create several query variables, here for the average change in length from one F to the next F: | ||
+ | <code java> | ||
+ | float m =mean(((*f1: | ||
+ | </ | ||
+ | |||
+ | |||
+ | This can be combined with any other expression, yet it is important to keep in mind that the expressions on the right of the context query are repeated for each found pattern! | ||
+ | Therefore '' | ||
+ | |||
+ | ==== Ternary conditional operator ==== | ||
+ | |||
+ | An Ternary conditional operator is in simple terms a inline if else expression, using the following syntax | ||
+ | |||
+ | |||
groimp-platform/xl-lambda.1737644359.txt.gz · Last modified: 2025/01/23 15:59 by Tim