Skip to content

Commit

Permalink
Fix reductions on empty input sequence
Browse files Browse the repository at this point in the history
Refers #362

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information
kotarak authored and stuarthalloway committed Jun 4, 2010
1 parent 31c184a commit fb52b69
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/clj/clojure/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/clojure/test_clojure/sequences.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit fb52b69

Please sign in to comment.