Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed LOGIC-127, nom swapping now preserves vectors and maps

Signed-off-by: amin <nada.amin@epfl.ch>
  • Loading branch information...
commit d73c836c0d4bab2af12b4bdedb31daad4a661fb6 1 parent 7891002
@jirkamarsik jirkamarsik authored namin committed
View
12 src/main/clojure/clojure/core/logic/nominal.clj
@@ -61,7 +61,17 @@
(let [[tfirst s] (swap-noms (first t) swap s)
[tnext s] (swap-noms (next t) swap s)]
[(with-meta (cons tfirst tnext) (meta t)) s])
- [t s])))
+ [t s]))
+
+ clojure.lang.IPersistentVector
+ (swap-noms [t swap s]
+ (let [[ts s] (swap-noms (seq t) swap s)]
+ [(vec ts) s]))
+
+ clojure.lang.IPersistentMap
+ (swap-noms [t swap s]
+ (let [[tkvs s] (swap-noms (seq t) swap s)]
+ [(into {} tkvs) s])))
;; =============================================================================
;; Nom
View
8 src/test/clojure/clojure/core/logic/nominal/tests.clj
@@ -521,3 +521,11 @@
(nom/fresh [a b]
(!= (nom/tie a a) (nom/tie b b))))
'()))))
+
+(deftest test-logic-127-nomswap-maps
+ (is (= (run* [q]
+ (fresh [body]
+ (nom/fresh [a b]
+ (== (nom/tie a {:k a}) (nom/tie b body))
+ (== {:k q} body))))
+ '(a_0))))
Please sign in to comment.
Something went wrong with that request. Please try again.