metron-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cestella <...@git.apache.org>
Subject [GitHub] incubator-metron pull request #517: METRON-831: Add lambda expressions and r...
Date Sat, 08 Apr 2017 17:11:56 GMT
Github user cestella commented on a diff in the pull request:

    https://github.com/apache/incubator-metron/pull/517#discussion_r110522907
  
    --- Diff: metron-platform/metron-common/README.md ---
    @@ -73,6 +73,27 @@ Below is how the `==` operator is expected to work:
     
     The `!=` operator is the negation of the above.
     
    +## 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 variables
    +  * For instance, the lambda expression which calls `TO_UPPER` on a named argument `x`
could be 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 argument `x`
could be expressed as `x -> 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 expression
    +* `stellar_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 instance `MAP([ 'foo',
'bar'], (x) -> TO_UPPER(x) )` returns `[ 'FOO', 'BAR' ]`
    +* `FILTER` - Filters a list by a predicate in the form of a lambda expression.  For instance
`FILTER([ 'foo', 'bar'], (x ) -> x == 'foo' )` returns `[ 'foo' ]`
    +* `REDUCE` - Applies a function over a list of input.  For instance `MAP([ 'foo', 'bar'],
(x) -> TO_UPPER(x) )` returns `[ 'FOO', 'BAR' ]`
    --- End diff --
    
    Yep, agreed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message