(transduce xform f coll)
(transduce xform f init coll)
reduce with a transformation of f (xf). If init is not
supplied, (f) will be called to produce it. f should be a reducing
step function that accepts both 1 and 2 arguments, if it accepts
only 2 you can add the arity-1 with 'completing'. Returns the result
of applying (the transformed) xf to init and the first item in coll,
then applying xf to that result and the 2nd item, etc. If coll
contains no items, returns init and f is not called. Note that
certain transforms may inject or skip items.
Source
(defn
transduce
"reduce with a transformation of f (xf). If init is not\n supplied, (f) will be called to produce it. f should be a reducing\n step function that accepts both 1 and 2 arguments, if it accepts\n only 2 you can add the arity-1 with 'completing'. Returns the result\n of applying (the transformed) xf to init and the first item in coll,\n then applying xf to that result and the 2nd item, etc. If coll\n contains no items, returns init and f is not called. Note that\n certain transforms may inject or skip items."
([xform f coll] (transduce xform f (f) coll))
([xform f init coll]
(let [f (xform f) ret (reduce f init coll)] (f ret))))