0
在MiniZinc tutorial,我注意到endif
關鍵字在一系列條件語句的結束重複多次。是否可以在MiniZinc中編寫switch語句來替代這種冗長的語法?switch語句中MiniZinc
例如,我想更簡明地寫這個系列的條件語句:
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;
出人意料的是,[在MiniZinc教程](http://www.minizinc.org/downloads/doc-latest/minizinc-tute.pdf)沒有提到你在這裏所描述的'elseif'語法。我希望它會很快更新。 –
是的,「elseif的」沒有被提及,但有很多例子車型與其他'if'。也許「elseif」現在已被棄用。 – hakank
它更可能是本教程是過時的。在'elseif'語法比一個教程更簡明易讀。 –