[ 
https://issues.apache.org/jira/browse/METRON-1286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16271590#comment-16271590
 ] 

ASF GitHub Bot commented on METRON-1286:
----------------------------------------

Github user cestella commented on the issue:

    https://github.com/apache/metron/pull/823
  
    Slightly off topic (and not to dissuade from this good work which is much 
clearer), but as a bit of stellar code golf, I did find out that you can do 
this with `REDUCE`.
    
    For Numerical types (note val is mixed numeric types):
    ```
    [Stellar]>>> val := [1.2,2,3]
    [Stellar]>>> REDUCE(val, (ret, x) -> ret > x ? x : ret, GET_FIRST(val))
    1.2
    [Stellar]>>> MIN(val)
    1.2
    [Stellar]>>> REDUCE(val, (ret, x) -> ret < x ? x : ret, GET_FIRST(val))
    3
    [Stellar]>>> MAX(val)
    3
    ```
    
    For non-numeric but comparable types:
    ```
    [Stellar]>>> val := [ 'casey', 'stella' ]
    [Stellar]>>> MAX(val)
    stella
    [Stellar]>>> REDUCE(val, (ret, x) -> ret < x ? x : ret, GET_FIRST(val))
    stella
    [Stellar]>>> MIN(val)
    casey
    [Stellar]>>> REDUCE(val, (ret, x) -> ret > x ? x : ret, GET_FIRST(val))
    casey
    ```


> Add MAX & MIN Stellar functions 
> --------------------------------
>
>                 Key: METRON-1286
>                 URL: https://issues.apache.org/jira/browse/METRON-1286
>             Project: Metron
>          Issue Type: Improvement
>    Affects Versions: 0.4.1
>            Reporter: Jasper Knulst
>            Priority: Minor
>              Labels: features
>             Fix For: 0.4.2
>
>
> Currently Stellar lacks straightforward MAX & MIN functions that take just a 
> list of values as input.
> The functions STATS_MAX and STATS_MIN only take the internal Stellar 
> statistics object as input.
> Having MAX and MIN will be easier and understandable to most



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to