Update prolog samples

This commit is contained in:
Ted Nyman
2013-12-29 12:24:02 -08:00
parent fbcad41813
commit 016f9852d6
3 changed files with 92 additions and 3 deletions

View File

@@ -319,6 +319,10 @@
"Processing": [
".pde"
],
"Prolog": [
".pl",
".prolog"
],
"Protocol Buffer": [
".proto"
],
@@ -519,8 +523,8 @@
".gemrc"
]
},
"tokens_total": 439417,
"languages_total": 511,
"tokens_total": 439684,
"languages_total": 513,
"tokens": {
"ABAP": {
"*/**": 1,
@@ -38586,6 +38590,56 @@
"PI": 1,
"TWO_PI": 1
},
"Prolog": {
"-": 38,
"male": 3,
"(": 29,
"john": 2,
")": 29,
".": 17,
"peter": 3,
"female": 2,
"vick": 2,
"christie": 3,
"parents": 4,
"brother": 1,
"X": 3,
"Y": 2,
"F": 2,
"M": 2,
"turing": 1,
"Tape0": 2,
"Tape": 2,
"perform": 4,
"q0": 1,
"[": 12,
"]": 12,
"Ls": 12,
"Rs": 16,
"reverse": 1,
"Ls1": 4,
"append": 1,
"qf": 1,
"Q0": 2,
"Ls0": 6,
"Rs0": 6,
"symbol": 3,
"Sym": 6,
"RsRest": 2,
"once": 1,
"rule": 1,
"Q1": 2,
"NewSym": 2,
"Action": 2,
"action": 4,
"|": 7,
"Rs1": 2,
"b": 2,
"left": 4,
"stay": 1,
"right": 1,
"L": 2
},
"Protocol Buffer": {
"package": 1,
"tutorial": 1,
@@ -46930,6 +46984,7 @@
"PostScript": 107,
"PowerShell": 12,
"Processing": 74,
"Prolog": 267,
"Protocol Buffer": 63,
"Python": 5715,
"R": 175,
@@ -47068,6 +47123,7 @@
"PostScript": 1,
"PowerShell": 2,
"Processing": 1,
"Prolog": 2,
"Protocol Buffer": 1,
"Python": 7,
"R": 2,
@@ -47111,5 +47167,5 @@
"Xtend": 2,
"YAML": 1
},
"md5": "3969c4c97eb1dc3e7063e0478775dd9a"
"md5": "2418026a91f287eda7faac9b75d06236"
}

View 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
View 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]).