Stellar Language Lambda Expressions
Stellar provides the capability to pass lambda expressions to functions which wish to support that layer of indirection. The syntax is:
(named_variables) -> stellar_expression
: Lambda expression with named variablesFor instance, the lambda expression which calls
TO_UPPER
on a named argumentx
could be expressed as(x) -> TO_UPPER(x)
.var -> stellar_expression
: Lambda expression with a single named variable,var
For instance, the lambda expression which calls
TO_UPPER
on a named argumentx
could be expressed asx -> TO_UPPER(x)
. Note, this is more succinct but equivalent to the example directly above.
() -> stellar_expression
: Lambda expression with no named variables.If no named variables are needed, you may omit the named variable section. For instance, the lambda expression which returns a constant
false
would be() -> false
where
named_variables
is a comma separated list of variables to use in the Stellar expressionstellar_expression
is an arbitrary stellar expression
In the core language functions, we support basic functional programming primitives such as
MAP
- Applies a lambda expression over a list of input. For instanceMAP([ 'foo', 'bar'], (x) -> TO_UPPER(x) )
returns[ 'FOO', 'BAR' ]
FILTER
- Filters a list by a predicate in the form of a lambda expression. For instanceFILTER([ 'foo', 'bar'], (x ) -> x == 'foo' )
returns[ 'foo' ]
REDUCE
- Applies a function over a list of input. For instanceREDUCE([ 1, 2, 3], (sum, x) -> sum + x, 0 )
returns6
Important | |
---|---|
Any property that is managed by Ambari should only be modified via Ambari. Otherwise, when you restart a service, Ambari might overwrite your updates. For more information, see Updating Properties. |