Permalink
Browse files

LOGIC-111: conda regression

`conda` and `condu` implementations were both incorrect for the unit
case. Both now use `(reduce bind b gs)`. Added test for the regression.
  • Loading branch information...
swannodette committed Feb 13, 2013
1 parent 79092d4 commit 1d1724bc66b344551619c32331393a811fe7714a
Showing with 15 additions and 15 deletions.
  1. +7 −15 src/main/clojure/clojure/core/logic.clj
  2. +8 −0 src/test/clojure/clojure/core/logic/tests.clj
@@ -1236,20 +1236,16 @@
(extend-protocol IIfA
nil
(ifa [b gs c]
- (when c
- (force c)))
+ (when c
+ (force c)))
Substitutions
(ifa [b gs c]
- (loop [b b [g0 & gr] gs]
- (if g0
- (when-let [b (g0 b)]
- (recur b gr))
- b)))
+ (reduce bind b gs))
clojure.lang.Fn
(ifa [b gs c]
- (-inc (ifa (b) gs c)))
+ (-inc (ifa (b) gs c)))
Choice
(ifa [b gs c]
@@ -1258,16 +1254,12 @@
(extend-protocol IIfU
nil
(ifu [b gs c]
- (when c
- (force c)))
+ (when c
+ (force c)))
Substitutions
(ifu [b gs c]
- (loop [b b [g0 & gr] gs]
- (if g0
- (when-let [b (g0 b)]
- (recur b gr))
- b)))
+ (reduce bind b gs))
clojure.lang.Fn
(ifu [b gs c]
@@ -1538,6 +1538,14 @@
(== q (RecordTest. 1 2)))
(list #clojure.core.logic.tests.RecordTest{:a 1, :b 2}))))
+(deftest test-111-conda-regression
+ (is (= (run* [x]
+ (conda
+ [succeed
+ (project [x] succeed)
+ (project [x] succeed)]))
+ '(_0))))
+
;; =============================================================================
;; cKanren

0 comments on commit 1d1724b

Please sign in to comment.