Created
July 21, 2018 04:04
-
-
Save yycking/a8da9b80ea1c121b9d09c22384f1fd30 to your computer and use it in GitHub Desktop.
test for prolog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % 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