Permalink
Browse files

Fix reductions on empty input sequence

Refers #362

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information...
kotarak authored and stuarthalloway committed May 27, 2010
1 parent 31c184a commit fb52b69d75868e4ce49d0123bc1ceaae8d6f5fe8
Showing with 3 additions and 1 deletion.
  1. +1 −1 src/clj/clojure/core.clj
  2. +2 −0 test/clojure/test_clojure/sequences.clj
View
@@ -5555,7 +5555,7 @@
(lazy-seq
(if-let [s (seq coll)]
(reductions f (first s) (rest s))
- (f))))
+ (list (f)))))
([f init coll]
(cons init
(lazy-seq
@@ -1138,6 +1138,8 @@
{1 4 2 2 3 1} '(1 1 1 1 2 2 3)))
(deftest test-reductions
+ (is (= (reductions + nil)
+ [0]))
(is (= (reductions + [1 2 3 4 5])
[1 3 6 10 15]))
(is (= (reductions + 10 [1 2 3 4 5])

0 comments on commit fb52b69

Please sign in to comment.