cgrand / xforms

Extra transducers and reducing fns for Clojure(script)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect behavior of combination of partition and reduce

coder11 opened this issue · comments

commented

When you use partition to group input seq into batches, then map to do some processing and finally reduce to aggregate result, transduce behavior is incorrect. It returns empty vector instead when batch size is divisible of seq count.

(transduce
 (comp
  (x/partition 2 2 nil)
  (map count)
  (x/reduce +))
 conj
 (range 4)) => []

However, without reduce result is correct:

(transduce
 (comp
  (x/partition 2 2 nil)
  (map count))
 conj
 (range 4)) => [2 2]

Also, if batch does not divide evenly, everything works fine:

(transduce
 (comp
  (x/partition 2 2 nil)
  (map count)
  (x/reduce +))
 conj
(range 5)) => [5]

version 0.9.2

Published 0.9.3 which includes the fix. Thanks for the report!