Permalink
Browse files

* src/main/clojure/clojure/core/logic.clj: ConstraintStore no longer …

…implements ILookup
  • Loading branch information...
1 parent 0612586 commit 2648ba2f3bc6710f41de654582f165a8a5d0c7c9 David Nolen committed Aug 1, 2012
Showing with 8 additions and 15 deletions.
  1. +6 −13 src/main/clojure/clojure/core/logic.clj
  2. +2 −2 src/test/clojure/clojure/core/logic/tests.clj
View
19 src/main/clojure/clojure/core/logic.clj
@@ -107,7 +107,7 @@
(checkc [this c s])
(remc [this c])
(runc [this c])
- (constraints [this x])
+ (constraints-for [this x])
;;(update-proc [this id proc])
)
@@ -775,8 +775,9 @@
(ConstraintStore. nkm ncm cid running)))
(runc [this c]
(ConstraintStore. km cm cid (conj running (id c))))
- (constraints [this x]
- (map cm (get km x)))
+ (constraints-for [this x]
+ (when-let [ids (get km x)]
+ (map cm (remove running ids))))
;; (update-proc [this id proc]
;; (if-let [c (get cm id)]
;; (let [ncm (assoc cm id (with-proc c proc))]
@@ -792,15 +793,7 @@
(throw (Error. (str "constraint store assoc expected logic var key: " k))))
(let [nkm (update-in km [k] (fnil (fn [s] (conj s cid)) #{}))
ncm (assoc cm cid v)]
- (ConstraintStore. nkm ncm cid running)))
- clojure.lang.ILookup
- (valAt [this k]
- (when-let [ids (get km k)]
- (map cm (remove running ids))))
- (valAt [this k not-found]
- (if-let [v (.valAt this k)]
- v
- not-found)))
+ (ConstraintStore. nkm ncm cid running))))
(defn make-cs []
(ConstraintStore.
@@ -3007,7 +3000,7 @@
(if (or (zero? (count cs))
(nil? (seq xs)))
s#
- (let [xcs (get cs (first xs))]
+ (let [xcs (constraints-for cs (first xs))]
(if (seq xcs)
(composeg
(run-constraints xcs)
View
4 src/test/clojure/clojure/core/logic/tests.clj
@@ -1719,7 +1719,7 @@
w (lvar 'w)
c (fdc (+fdc u v w))
^clojure.core.logic.ConstraintStore csp (addc (make-cs) c)
- sc (first (get csp u))]
+ sc (first (constraints-for csp u))]
(is (= c sc))
(is (= (id sc) 0))
(is (= (count (.km csp)) 2))
@@ -1769,7 +1769,7 @@
w (lvar 'w)
c (fdc (+fdc u v w))
s ((addcg c) empty-s)
- c (first (get (.cs s) u))
+ c (first (constraints-for (.cs s) u))
s (-> s
(ext-no-check u 1)
(ext-no-check w 2))

0 comments on commit 2648ba2

Please sign in to comment.