Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix ancestor

  • Loading branch information...
commit fd9f0f044b64db1f0cad9e65221d5fb20bfb7197 1 parent c87e04a
@samth authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 ancestor.rkt
View
13 ancestor.rkt
@@ -3,15 +3,20 @@
Semi-literate programming works for datalog as well
This is the data portion -- we just declare some basic facts.
-> parent(john, douglas)
+> parent(john, douglas).
+> parent(mary, john).
The `ancestor` relation computes the transitive closure of the
`parent` relation.
> ancestor(A, B) :-
-> parent(A, B)
+> parent(A, B).
> ancestor(A, B) :-
> parent(A, C),
-> ancestor(C, B)
+> ancestor(C, B).
-And that's all she wrote.
+Now we can ask a question.
+
+> ancestor(mary,A)?
+
+And then we get answers.
Please sign in to comment.
Something went wrong with that request. Please try again.