mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 20:38:47 +00:00
Update prolog samples
This commit is contained in:
12
samples/Prolog/test-prolog.prolog
Normal file
12
samples/Prolog/test-prolog.prolog
Normal file
@@ -0,0 +1,12 @@
|
||||
-/* Prolog test file */
|
||||
-male(john).
|
||||
-male(peter).
|
||||
-
|
||||
-female(vick).
|
||||
-female(christie).
|
||||
-
|
||||
-parents(john, peter, christie).
|
||||
-parents(vick, peter, christie).
|
||||
-
|
||||
-/* X is a brother of Y */
|
||||
-brother(X, Y) :- male(X), parents(X, F, M), parents(Y, F, M).
|
||||
21
samples/Prolog/turing.pl
Normal file
21
samples/Prolog/turing.pl
Normal file
@@ -0,0 +1,21 @@
|
||||
-turing(Tape0, Tape) :-
|
||||
- perform(q0, [], Ls, Tape0, Rs),
|
||||
- reverse(Ls, Ls1),
|
||||
- append(Ls1, Rs, Tape).
|
||||
-
|
||||
-perform(qf, Ls, Ls, Rs, Rs) :- !.
|
||||
-perform(Q0, Ls0, Ls, Rs0, Rs) :-
|
||||
- symbol(Rs0, Sym, RsRest),
|
||||
- once(rule(Q0, Sym, Q1, NewSym, Action)),
|
||||
- action(Action, Ls0, Ls1, [NewSym|RsRest], Rs1),
|
||||
- perform(Q1, Ls1, Ls, Rs1, Rs).
|
||||
-
|
||||
-symbol([], b, []).
|
||||
-symbol([Sym|Rs], Sym, Rs).
|
||||
-
|
||||
-action(left, Ls0, Ls, Rs0, Rs) :- left(Ls0, Ls, Rs0, Rs).
|
||||
-action(stay, Ls, Ls, Rs, Rs).
|
||||
-action(right, Ls0, [Sym|Ls0], [Sym|Rs], Rs).
|
||||
-
|
||||
-left([], [], Rs0, [b|Rs0]).
|
||||
-left([L|Ls], Ls, Rs, [L|Rs]).
|
||||
Reference in New Issue
Block a user