Skip to content

Instantly share code, notes, and snippets.

@yycking
Created July 21, 2018 04:04
Show Gist options
  • Select an option

  • Save yycking/a8da9b80ea1c121b9d09c22384f1fd30 to your computer and use it in GitHub Desktop.

Select an option

Save yycking/a8da9b80ea1c121b9d09c22384f1fd30 to your computer and use it in GitHub Desktop.
test for prolog
% Prolog寫起來,真的很愉悅
%事實
母(毛福梅, 蔣經國).
母(蔣方良, 蔣孝文).
母(蔣方良, 蔣孝武).
父(蔣介石, 蔣經國).
父(蔣經國, 蔣孝文).
父(蔣經國, 蔣孝武).
父(蔣經國, 章孝嚴).
父(蔣經國, 章孝慈).
%規則
父母(A, B) :-
母(A, B).
父母(A, B) :-
父(A, B).
兄弟(A, B) :-
父(C, A),
父(C, B),
A\=B.
列印 :-
兄弟(蔣孝文, X),
write(X),
write("\n"),
false.
main:-
列印, halt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment