chore: Demo & examples
This commit is contained in:
parent
61178cbeac
commit
b294467587
9 changed files with 228 additions and 23 deletions
27
examples/meta/interpreter.pl
Normal file
27
examples/meta/interpreter.pl
Normal file
|
@ -0,0 +1,27 @@
|
|||
interpreter :-
|
||||
interpreter_prompt,
|
||||
read(Goal),
|
||||
interpreter(Goal).
|
||||
|
||||
interpreter_prompt :- write('Next Command ?-- ').
|
||||
|
||||
interpreter(exit) :- !.
|
||||
interpreter(Goal) :-
|
||||
ground(Goal), !,
|
||||
solve_ground(Goal),
|
||||
interpreter.
|
||||
interpreter(Goal) :-
|
||||
solve(Goal),
|
||||
interpreter.
|
||||
|
||||
solve_ground(Goal) :-
|
||||
call(Goal),
|
||||
!,
|
||||
writeln('True :)').
|
||||
solve_ground(_) :- writeln('False :(').
|
||||
|
||||
solve(Goal) :-
|
||||
call(Goal),
|
||||
writeln(Goal),
|
||||
fail.
|
||||
solve(_) :- writeln('No more solutions :/').
|
Reference in a new issue