イフコンピュータ > MINERVA > マニュアル > レファレンス > 述語 > 論理と制御 > ';'(If-then-else)/2

';'(If-then-else)/2

MINERVA
ifcomputer logo
f
Expert Services on the Web

一つのゴールと、どちらかのゴールを関係づける。

+Ifゴール -> +Thenゴール; +Elseゴール
;((Ifゴール-> +Thenゴール), +Elseゴール)

もし、Ifゴール が成功すれば、Thenゴールは実行される。
もし、Ifゴール が失敗すれば、Elseゴールが実行される。
もし、if either Thenゴール あるいはElseゴール どちらかが成功すれば、'->'/2 は成功する。

','/2とは2点の大きな違いがある。:

  • Ifゴールは一度だけ成功する。
  • もし、Ifゴール がサブゴール、カット ('!'/0)を持っていても、このカット は、IfGゴールの外側に影響を与えない。

';'/2 は、右結合性で優先順位クラス1100の組み込み挿入関数である。

'->'/2 は、右結合性で優先順位クラス1050の組み込み挿入関数である。 (関連 current_op/3).

引数

Ifゴール                 ゴール
Thenゴール               ゴール
Elseゴール               ゴール

Day=sunny -> Weather=sunshine; Weather=raining. 成功.
X=b, X=a -> write(a); write(b). X <- b の代入で、成功。 現在出力ストリーム 'b'に出力。

標準

この述語は、ISO-Prolog標準に含まれる。

関連

abort/0, break/0, call/1, fcall/1, catch/3, ','(conjunction)/2, '!'(cut)/0, ';'(disjunction)/2, fail/0, true/0, halt/0/1, '->'(if-then)/2, '\+'(not provable)/1, once/1, repeat/0, throw/1.

document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Predicates/logic_and_control/if_then_else/print_jp.html
published 2008/8/25 update 2001/2/7 (c) 1996-2006 IF Computer Japan
IF Computer 〒113-0022 Tel 03-5814-3352 start (AT) ifcomputer.com
Customer Support 東京都文京区千駄木5-28-2   http://www.ifcomputer.co.jp
戻る> managed with ubiCMS