Skip to content

Commit

Permalink
CLJS-792: Implement IReduce on PersistentArrayMap
Browse files Browse the repository at this point in the history
  • Loading branch information
jonase authored and swannodette committed May 21, 2014
1 parent f9a3337 commit 76cf7c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/cljs/cljs/core.cljs
Expand Up @@ -4388,7 +4388,13 @@ reduces them without incurring seq initialization"
@init
(recur (+ i 2) init)))
init))))


IReduce
(-reduce [coll f]
(seq-reduce f coll))
(-reduce [coll f start]
(seq-reduce f start coll))

IFn
(-invoke [coll k]
(-lookup coll k))
Expand Down
4 changes: 3 additions & 1 deletion test/cljs/cljs/reducers_test.cljs
Expand Up @@ -24,7 +24,9 @@
(r/fold g f {:a 1 :b 2 :c 3})
[#{:a :b :c} #{1 2 3}]))
(let [m (into {} (for [x (range 2048)] [x (- x)]))]
(assert (= (r/reduce f (g) m) (r/fold g f m))))))
(assert (= (r/reduce f (g) m) (r/fold g f m)))))
;; CLJS-792
(assert (= (into [] (r/map identity {})) [])))

(defn test-all []
(test-builtin-impls))

0 comments on commit 76cf7c2

Please sign in to comment.