Mercurial > repos > other > SevenLanguagesInSevenWeeks
annotate 3-Prolog/day2-unification.pl @ 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 | |
children |
rev | line source |
---|---|
58 | 1 % Unification works both sides of the equals: |
2 % (A, 2, C) = (1, B, 3). | |
3 % We can't actually run this from a file, because Prolog. We get: | |
4 % | |
5 % native code procedure (=)/2 cannot be redefined (ignored) | |
6 % | |
7 % But we can run it from the REPL. | |
8 % | |
9 % Lists have heads and tails: | |
10 % | |
11 % [a, b, c] = [Head|Tail]. | |
12 % | |
13 % Underscore is the wildcard variable: | |
14 % | |
15 % [a, b, c] = [_|Tail]. | |
16 % | |
17 % Note: It's not magic "Head|Tail", it's "[X|Y]" notation |