• (magic-transform rs)
  • (magic-transform rs i-preds)
Return a magic transformation of an adorned rules-set (rs). The
(i-preds) are the predicates of the intension database. These
default to the predicates within the rules-set.

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/magic.clj:98 top

(defn magic-transform
  "Return a magic transformation of an adorned rules-set (rs).  The
   (i-preds) are the predicates of the intension database.  These
   default to the predicates within the rules-set."
  ([rs]
     (magic-transform rs (all-predicates rs)))
  ([rs i-preds]
     (let [not-duplicate? (fn [l mh bd]
                            (or (not (empty? bd))
                                (not (= (magic-literal l)
                                        mh))))
           xr (fn [rs rule]
                (let [head (:head rule)
                      body (:body rule)
                      mh (magic-literal head)
                      answer-rule (build-rule head
                                              (concat [mh] body))
                      step (fn [[rs bd] l]
                             (if (and (i-preds (literal-predicate l))
                                      (not-duplicate? l mh bd))
                               (let [nr (build-rule (magic-literal l)
                                                    (concat [mh] bd))]
                                 [(conj rs nr) (conj bd l)])
                               [rs (conj bd l)]))
                      [nrs _] (reduce step [rs []] body)]
                  (conj nrs answer-rule)))]
     (reduce xr empty-rules-set rs))))
Vars in clojure.contrib.datalog.magic/magic-transform: defn let reduce
Used in 0 other vars

Comments top

No comments for magic-transform. Log in to add a comment.