Różnice
Różnice między wybraną wersją a wersją aktualną.
|
|
pl:prolog:pllib:answers_storing [2019/06/27 15:50] |
pl:prolog:pllib:answers_storing [2019/06/27 15:50] (aktualna) |
| ====== Answers storing ====== |
| {{tag>knowledge_base interactive}} |
| ===== Description ===== |
| Program remember answer |
| |
| **Source**: Building Expert Systems in PROLOG Publisher |
| ===== Download ===== |
| Program source code: {{answers_storing.pl}} |
| ===== Listing ===== |
| <code prolog> |
| ask(A, V):- |
| known(yes, A, V), % succeed if true |
| !. % stop looking |
| |
| ask(A, V):- |
| known(_, A, V), % fail if false |
| !, fail. |
| |
| ask(A, V):- |
| write(A:V), % ask user |
| write('? : '), |
| read(Y), % get the answer |
| asserta(known(Y, A, V)), % remember it |
| Y == yes. % succeed or fail |
| </code> |
| ===== Comments ===== |
| |