first
OPL function to return the first element in a set.
Purpose
OPL function to return the first element in a set. For the scheduling function on interval variables, see first (scheduling).
| type |
|---|
int, float, string, or a tuple type |
Syntax
int first({int})
float first({float})
string first({string})
<tuple type> first({<tuple type>})
Description
Returns the first element in a set. You can use this function within IBM ILOG Script statements by specifying the OPL namespace:
(Opl.xxx())
Example
The following code
{string} Days ={"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
string f = first(Days);
execute
{
writeln("first(",Days,") gives ",f);
}
initializes f to Monday. This also
indicates that sets in OPL are totally ordered according to their
order of appearance in the initialization.
Result
first( {"Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday"}) gives Monday