Apply the rule against db-1, adding the results to the appropriate
relation in db-2. The relation will be created if needed.
(defn apply-rule
"Apply the rule against db-1, adding the results to the appropriate
relation in db-2. The relation will be created if needed."
([db rule] (apply-rule db db rule))
([db-1 db-2 rule]
(trace-datalog (println)
(println)
(println "--------------- Begin Rule ---------------")
(println rule))
(let [head (:head rule)
body (:body rule)
step (fn [bs lit]
(trace-datalog (println bs)
(println lit))
(join-literal db-1 lit bs))
bs (reduce step empty-bindings body)]
(do (trace-datalog (println bs))
(project-literal db-2 head bs)))))
Comments top
No comments for apply-rule. Log in to add a comment.