Topic
1 reply Latest Post - ‏2014-05-26T07:42:19Z by AlexFleischer
Amani_Jerbi
Amani_Jerbi
7 Posts
ACCEPTED ANSWER

Pinned topic Max between two tuple elements

‏2014-05-23T23:25:26Z |

Hello, 
Please I have this tuple:

tuple route{
key int route_id;  
string origin; 
int origin_zone; 
string destination; 
int destinantion_zone;

}
and i need to compare the  int origin_zone with the int destinantion_zone  and pick the maximum one. 
when I write :
int  index_zone_route= max(e in Route1 union Route2)(e.destinantion_zone , e.origin_zone); it shows error because the comma doesnt work , how to write it then ? 

Thank you.

  • AlexFleischer
    AlexFleischer
    1068 Posts
    ACCEPTED ANSWER

    Re: Max between two tuple elements

    ‏2014-05-26T07:42:19Z  in response to Amani_Jerbi

    Hi,

    you should use maxl

    let me give you an example:

    tuple route{
    key int route_id;  
    string origin;
    int origin_zone;
    string destination;
    int destinantion_zone;

    }

    {route} Route1={<1,"1",1,"1",2>};
    {route} Route2={<2,"2",2,"3",4>};

    int  index_zone_route= max(e in Route1 union Route2) maxl(e.destinantion_zone , e.origin_zone);

    execute
    {
      writeln(index_zone_route);
    }