Permalink
Browse files

* src/main/clojure/clojure/core/logic.clj: actually fix to-stream. 0.7.4

  • Loading branch information...
1 parent e86b7ff commit 4cc9cb031fc9ce44daddbd86b06d15aeafac09fc David Nolen committed May 17, 2012
Showing with 13 additions and 7 deletions.
  1. +5 −6 src/main/clojure/clojure/core/logic.clj
  2. +8 −1 src/test/clojure/clojure/core/logic/tests.clj
@@ -1456,10 +1456,10 @@
;; Rel
(defn to-stream [aseq]
- (when (seq aseq)
- (choice (first aseq)
- (let [aseq (drop-while #(or (nil? %) (false? %)) (next aseq))]
- (fn [] (to-stream aseq))))))
+ (let [aseq (drop-while #(or (nil? %) (false? %)) aseq)]
+ (when (seq aseq)
+ (choice (first aseq)
+ (fn [] (to-stream (next aseq)))))))
(defmacro def-arity-exc-helper []
(try
@@ -1603,8 +1603,7 @@
(->> set#
(map (fn [cand#]
(when-let [~'a (clojure.core.logic/unify ~'a [~@as] cand#)]
- ~'a)))
- (remove nil?)))))))))))
+ ~'a)))))))))))))
;; TODO: Should probably happen in a transaction
@@ -1286,4 +1286,11 @@
(deftest test-34-unify-with-metadata
(is (run* [q]
(== q (quote ^:haz-meta-daytuhs (form form form))))
- '((^:haz-meta-daytuhs (form form form)))))
+ '((^:haz-meta-daytuhs (form form form)))))
+
+;; =============================================================================
+;; nil & false to-stream
+
+(deftest nil-or-false-in-stream []
+ (is (= (take 1 (take* (to-stream [nil false (cons empty-s nil)])))
+ (cons empty-s nil))))

0 comments on commit 4cc9cb0

Please sign in to comment.