card
OPL function for the cardinality
Purpose
OPL function to return the number of items in a set or a range.
type |
---|
int |
Syntax
card(set) card(range)
Description
The cardinality function returns the number of items in a set or a range. You can use this function within IBM ILOG Script statements by specifying the OPL namespace:
( Opl.xxx() )
Example
{string} S={ "France" ,"Germany", "Italy"};
int cardofS=card(S);
range r=2..5;
int cardofr=card(r);
execute
{
writeln("card(",S,") gives ",cardofS);
writeln("card(",r,") gives ",cardofr);
}
Result
card( {"France" "Germany" "Italy"}) gives 3
card(2..5) gives 4