在MiniZinc 教程中,我注意到endif
关键字在一系列条件语句的末尾重复了很多次。是否可以在 MiniZinc 中编写 switch 语句来替代这种冗长的语法?
例如,我想把这一系列条件语句写得更简洁:
predicate examplePredicate(var int:x, int:s) =
if s == 1
% some code goes here
else if s == 2 then
% some code goes here
else if s == 3 then
% some code goes here
else if s == 4 then
% some code goes here
else
% some code goes here
endif endif endif endif;