Mercurial > repos > other > SevenLanguagesInSevenWeeks
comparison 3-Prolog/readme.txt @ 58:90c4b7f28690
Add initial Day 2 notes for Prolog
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 26 Sep 2017 20:58:49 +0100 |
parents | 005ae3fad18f |
children | 05871e7ac124 |
comparison
equal
deleted
inserted
replaced
57:c9873b78e8c2 | 58:90c4b7f28690 |
---|---|
10 | 10 |
11 When you ask a question with a placeholder, the placeholder has to be capitalised. Lower-case makes it an atom. | 11 When you ask a question with a placeholder, the placeholder has to be capitalised. Lower-case makes it an atom. |
12 When Prolog returns its answers, type ";" to get the next response or "a" to get all. Sometimes Prolog will end multiple responses | 12 When Prolog returns its answers, type ";" to get the next response or "a" to get all. Sometimes Prolog will end multiple responses |
13 with "no", sometimes with "yes". This depends on whether it needs to do more calculations to check for more answers ("no") | 13 with "no", sometimes with "yes". This depends on whether it needs to do more calculations to check for more answers ("no") |
14 or whether it knows it successfully gave you everything ("yes"). | 14 or whether it knows it successfully gave you everything ("yes"). |
15 | |
16 Rules don't need to be defined once. If you define the following: | |
17 | |
18 ancestor(X, Y) :- father(X, Y). | |
19 ancestor(X, Y) :- father(X, Z), ancestor(Z, Y). | |
20 | |
21 then Prolog will check both "definitions" of the rule. | |
22 | |
23 (Note: putting the recursive "ancestor/2" call at the end is called "tail recursion" and the language can optimise it to | |
24 reduce call stack exhaustion issues) |