Hi,
The fact that when calling (fold combinef reducef coll):
* (combinef) is directly used as the init for the group reduce,
* and the return value of the group reduce is directly passed to combinef.
preclude using fold instead of a reduce which uses transients (eg #'frequencies).
To fix this issue there should be a way to specify a "cleanup" function to call on the return of reduce.
A potential design choice would be to use the 1-arg arity of combine (that would thus acts as the unit function mapping to the monoid domain)
(r/fold
(fn
([] (transient {}))
([tm] (persistent! tm))
([a b] (merge-with + a b)))
(fn [counts x]
(assoc! counts x (inc (get counts x 0))))
coll)
This would be a breaking change for current combinef functions whose 1-arg arity is not the identity.
Is there any interest in this line of work? Or what's the suggested work around?
Thanks,
Christophe