開発環境
- OS X El Capitan - Apple (OS)
- Emacs (Text Editor)
- Prolog (プログラミング言語)
- GProlog(GNU Prolog)(処理系)
7つの言語 7つの世界 (Bruce A. Tate (著)、まつもとゆきひろ (監訳)、田和 勝 (翻訳)、オーム社)の第4章(Prolog)、4.2(1日目: 素晴らしいドライバー)、セルフスタディ1日目.を取り組んでみる。
セルフスタディ1日目.
コード(Emacs)
book(title1, author1). book(title2, author2). book(title3, author1). book(title4, author1). book(title5, author2). music(musician1, piano). music(musician2, guitar). music(musician3, pian). music(musician4, guitar). music(musician5, pian). category(musician1, classic). category(musician2, pop). category(musician3, classic). category(musician4, classic). category(musician5, pop). guitarlist_pop(X) :- music(X, guitar), category(X, pop).
入出力結果(Terminal)
GNU Prolog 1.4.4 (64 bits) Compiled Feb 5 2016, 06:20:25 with /opt/local/bin/gcc-apple-4.2 By Daniel Diaz Copyright (C) 1999-2013 Daniel Diaz | ?- ['sample.pl']. compiling …/sample.pl for byte code... …/sample.pl compiled, 19 lines read - 2165 bytes written, 24 ms (3 ms) yes | ?- book(X, author1). X = title1 ? ; X = title3 ? a X = title4 (1 ms) no | ?- book(X, author2). X = title2 ? a X = title5 yes | ?- book(X, author3). no | ?- guitarlist_pop(X). X = musician2 ? a no | ?- Process prolog finished
0 コメント:
コメントを投稿