prevc
A circular version of the function prev
Purpose
OPL function.
A circular version of the function prev.
| type |
|---|
int, float, string, or a tuple type |
Syntax
int prevc({int},int)
int prevc({int},int,int)
float prevc({float},float)
float prevc({float},float,int)
string prevc({string},string)
string prevc({string},string,int)
<tuple type> prevc({<tuple type>},<tuple type>)
<tuple type> prevc({<tuple type>},<tuple type>,int)
Description
prevc is a circular version of the function prev and considers that the predecessor of the first
element of the type is the last element. You can use this function
within IBM ILOG Script statements by specifying the OPL namespace:
( Opl.xxx() )
Example
{string} Days ={"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
string p1 = prevc(Days,"Monday");
string p2 = prevc(Days,"Thursday",5);
execute
{
writeln("prevc(Days,\"Monday\") gives ",p1);
writeln("prevc(Days,\"Thursday\",5) gives ",p2);
}
Result
prevc(Days,"Monday") gives Sunday
prevc(Days,"Thursday",5) gives Saturday