Interactive shell

Description

An interactive shell

Source: The Art of Prolog

Download

Program source code: interactive_shell.pl

Listing

     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

Comments

pl/prolog/pllib/interactive_shell.txt · ostatnio zmienione: 2017/07/17 08:08 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0