Skip to content

Instantly share code, notes, and snippets.

@sudowork
Last active December 12, 2015 04:28
Show Gist options
  • Save sudowork/4714251 to your computer and use it in GitHub Desktop.
Save sudowork/4714251 to your computer and use it in GitHub Desktop.
% Multiple rules with the same signature:
ancestor(X, Y) :- father(X, Y). % base case first
ancestor(X, Y) :- father(X, Z), ancestor(Z, Y). % we recursively call ancestor
% Alternatively, we can write it this way using a logical OR:
ancestor(X, Y) :- father(X, Y); % we use a semicolon to distinguish between clauses
father(X, Z), ancestor(Z, Y).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment