Closed coder11 closed 7 years ago
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
(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
Good catch, there's a missing call to rf on this line https://github.com/cgrand/xforms/blob/master/src/net/cgrand/xforms.cljc#L333
rf
Published 0.9.3 which includes the fix. Thanks for the report!
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.However, without reduce result is correct:
Also, if batch does not divide evenly, everything works fine:
version 0.9.2