(deftype ArrayChunk [arr off end]
;; ...
IReduce
(-reduce [coll f]
(ci-reduce coll f (aget arr off) (inc off))) ;; should be (if (< off end) (ci-reduce coll f (aget arr off) 1) 0)
(-reduce [coll f start]
(ci-reduce coll f start off))) ;; should be (ci-reduce coll f start 0)
Environment
None
Activity
David Nolen
August 14, 2012 at 12:29 PM
Thanks for the report. ArrayChunk is an implementation detail - do these conditions actually arise?
(reduce + (array-chunk (array 1 2 3 4) 1 3)) => 2 (instead of 5) (reduce + 0 (array-chunk (array 1 2 3 4) 1 3)) => 3 (instead of 5) (reduce + (array-chunk (array 1 2 3 4) 1 1)) => 2 (instead of 0)In src/cljs/cljs/core.cljs, line #1817:
(deftype ArrayChunk [arr off end] ;; ... IReduce (-reduce [coll f] (ci-reduce coll f (aget arr off) (inc off))) ;; should be (if (< off end) (ci-reduce coll f (aget arr off) 1) 0) (-reduce [coll f start] (ci-reduce coll f start off))) ;; should be (ci-reduce coll f start 0)