sitelogo
バックトラックをし、Epilogを持つプログラム例
MINERVA superseeded IF/Prolog. Please see http://www.ifcomputer.co.jp/MINERVA for details.

We discontinued to sell IF/Prolog Dec 31. 2003. For current customers, we continue to provide professional support for IF/Prolog until Dec 31, 2008.

次の例は、必要でなくなったファイルを閉じる時に、epilogの機能がどのように使われるかを示しています。”readatom”という関数は、第1引数で指定されるファイルをオ−プンし、ファイルの最初の行を第2引数と単一化したアトムとして返します。バックトラックがおきると、第2引数を2,3,4行目と次々に単一化します。述語は、以下のように呼び出されます。(file1の内容は下に示してあります)

 ?- readatom(file1, P).  epilog enabled  P = 12345678;  P = abcdefghij;  P = 987654321;  start of epilog  file closed by epilog  no  ?- readatom(file1, P), write(P), nl, !, fail.  epilog enabled  123456789  start of epilog  file closed by epilog  no  ?-

file1の内容: 12345678 abcdefghij 987654321


readatom.cのリスト
プリプロセッサによる展開前と後のreadatom.cのリスト

Darueber read on...
scroll to top managed with ubiCMS