• (project-literal db lit bs)
  • (project-literal db lit bs var?)
Project a stream of bindings onto a literal/relation. Returns a new
db.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/datalog/literals.clj:392 top

(defn project-literal
  "Project a stream of bindings onto a literal/relation. Returns a new
   db."
  ([db lit bs] (project-literal db lit bs is-var?))
  ([db lit bs var?]
     (assert (= (:literal-type lit) ::literal))
     (let [rel-name (literal-predicate lit)
           columns (-> lit :term-bindings keys)
           idxs (vec (get-adorned-bindings (literal-predicate lit)))
           db1 (ensure-relation db rel-name columns idxs)
           rel (get-relation db1 rel-name)
           step (fn [rel bindings]
                  (let [step (fn [t [k v]]
                               (if (var? v)
                                 (assoc t k (bindings v))
                                 (assoc t k v)))
                        tuple (reduce step {} (:term-bindings lit))]
                    (add-tuple rel tuple)))]
       (replace-relation db rel-name (reduce step rel bs)))))
Vars in clojure.contrib.datalog.literals/project-literal: = assert defn let reduce
Used in 0 other vars

Comments top

No comments for project-literal. Log in to add a comment.