Switch statements in MiniZinc -


in minizinc tutorial, noticed endif keyword repeated many times @ end of series of conditional statements. possible write switch statements in minizinc alternative verbose syntax?

for example, i'd write series of conditional statements more concisely:

predicate examplepredicate(var int:x, int:s) = if s == 1     % code goes here else if s == 2     % code goes here else if s == 3     % code goes here else if s == 4     % code goes here else     % code goes here endif endif endif endif; 

the multiple "endif" not necessary. can use "elseif" instead of "else if".

predicate examplepredicate(var int:x, int:s) =   if s == 1      % code goes here elseif s == 2      % code goes here elseif s == 3      % code goes here elseif s == 4      % code goes here else      % code goes here endif; 

note: if want (simple) lookup table, might use global constraint "table" instead. see section 4.1.3 in minizinc tutorial example.


Comments