Różnice
Różnice między wybraną wersją a wersją aktualną.
|
|
pl:prolog:pllib:interactive_shell [2019/06/27 15:50] |
pl:prolog:pllib:interactive_shell [2019/06/27 15:50] (aktualna) |
| ====== Interactive shell ====== |
| {{tag>expert_shell interactive}} |
| ===== Description ===== |
| An interactive shell |
| |
| **Source**: The Art of Prolog |
| ===== Download ===== |
| Program source code: {{interactive_shell.pl}} |
| ===== Listing ===== |
| <code prolog> |
| shell :- shell_prompt, read(Goal), shell(Goal). |
| |
| shell(exit) :- !. |
| shell(Goal) :- |
| ground(Goal), !, shell_solve_ground(Goal), shell. |
| shell(Goal) :- |
| shell_solve(Goal), shell. |
| |
| shell_solve(Goal) :- |
| Goal, write(Goal), nl, fail. |
| shell_solve(Goal) :- |
| write('No (more) solutions'), nl. |
| |
| shell_solve_ground(Goal) :- |
| Goal, !, write('Yes'), nl. |
| shell_solve_ground(Goal) :- |
| write('No'), nl. |
| |
| shell_prompt :- write('Next command? '). |
| |
| % Program 12.6 An interactive shell |
| </code> |
| ===== Comments ===== |
| |