1.2.0 permalink Arrow_down_16x16
  • (add-tuple db rel-name tuple)
  • (add-tuple rel tuple)
Two forms:

[db relation-name tuple] adds tuple to the named relation. Returns
the new database.

[rel tuple] adds to the relation object. Returns the new relation.

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

(defn add-tuple
  "Two forms:

   [db relation-name tuple] adds tuple to the named relation.  Returns
   the new database.

   [rel tuple] adds to the relation object.  Returns the new relation."
  ([db rel-name tuple]
     (assert (= (-> tuple keys set) (-> rel-name db :schema)))
     (assoc db rel-name (add-tuple (db rel-name) tuple)))
  ([rel tuple]
     (let [data (:data rel)
           new-data (conj data tuple)]
       (if (identical? data new-data) ; optimization hack!
         rel
         (let [idxs (add-to-indexes (:indexes rel) tuple)]
           (assoc rel :data new-data :indexes idxs))))))
Vars in clojure.contrib.datalog.database/add-tuple: -> = assert assoc defn identical? keys let set
Used in 0 other vars

Comments top

No comments for add-tuple. Log in to add a comment.