annotate 3-Prolog/day1-unification.pl @ 73:74976fddd25f

Ignore Erlang binary files and remove existing ones
author IBBoard <dev@ibboard.co.uk>
date Sat, 03 Feb 2018 19:52:45 +0000
parents 91d02b3d74f8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54
91d02b3d74f8 Write up "unification" code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 % "=" isn't assignment in Prolog, it is "unification" - finding something where
91d02b3d74f8 Write up "unification" code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 % both structures are identical
91d02b3d74f8 Write up "unification" code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 cat(lion).
91d02b3d74f8 Write up "unification" code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 cat(tiger).
91d02b3d74f8 Write up "unification" code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5
91d02b3d74f8 Write up "unification" code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 % This rule makes sure that X, Y and Z match a lion, a tiger and a bear (oh my!)
91d02b3d74f8 Write up "unification" code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 dorothy(X, Y, Z) :- X = lion, Y = tiger, Z = bear.
91d02b3d74f8 Write up "unification" code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8
91d02b3d74f8 Write up "unification" code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 % This rule checks whether both things are cats, if so then they are "twin_cats"
91d02b3d74f8 Write up "unification" code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 twin_cats(X, Y) :- cat(X), cat(Y).