一つのゴールともう一つのゴールを関係付けさせる。...
移動
次へ 前へ
上へ 最上
参考
abort/0
::(Apply)/2
break
call/1
fcall/1
catch/3
','(Conjunction)/2
!(Cut)/0
';'(Disjunction)/2
<-(Eval)/2
fail/0
halt/0/1
->(If-then)/2
';'(If-then-else)/2
'\+'/1
once/1
repeat/0
throw/1
true/0
イフコンピュータ > MINERVA > マニュアル > レファレンス > 述語 > 論理と制御 > ->(If-then)/2

->(If-then)/2

一つのゴールともう一つのゴールを関係付けさせる。

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

もし、Ifゴールが成功すれば、Thenゴールは実行される。
もし、Ifゴールが失敗すれば、Thenゴール は実行されない。
もし、Ifゴール Thenゴール が両方とも成功すれば、'->'/2 も成功する。

','/2とは2つの重要な違いがある。:

  • Thenゴール だけが、バックトラックされる。Ifゴールは一度だけ成功する。
  • もし、Ifゴール がサブゴールと、カット ('!'/0)も持っていても、このカット は、Ifゴールの外に何の影響も与えない。

'->'/2 は、右結合性で優先順位クラス1500の組み込み挿入演算子である。(see also current_op/3).

引数

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

以下の節を持ったデータベースがあるとする。:
     colour(blue). colour(yellow).

colour(X) -> write(X). X <- blue で一度だけ代入成功。
で、現在出力ストリームに'blue'を出力する。
colour(X) -> X = yellow. 失敗.

標準

この述語は、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-else)/2, '\+'(not provable)/1, once/1, repeat/0, throw/1.

続く..
MINERVA
ifcomputer logo
f
Expert Services on the Web
言語
English
Japanese
サーバー
USA
Japan
サイトマップ
索引
目次
全体目次
全体索引
印刷向き
imode
PDA
探索
document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Predicates/logic_and_control/if_then/home_jp.html
published 2012/2/6 update 2001/2/7 (c) 1996-2009 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