From e92feae40aeb0f80df990fd261bb5982b1b5f674 Mon Sep 17 00:00:00 2001 From: Christophe Grand Date: Tue, 15 Sep 2015 14:11:39 +0200 Subject: [PATCH] Adds transducer arity to transjuxt. --- src/net/cgrand/xforms.clj | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/net/cgrand/xforms.clj b/src/net/cgrand/xforms.clj index cf149bf..b9eace7 100644 --- a/src/net/cgrand/xforms.clj +++ b/src/net/cgrand/xforms.clj @@ -298,10 +298,13 @@ (defn transjuxt "Performs several transductions over coll at once. xforms-map can be a map or vector. - Returns a map with the same keyset as xforms-map (or a vector of same size as xforms-map)." - [xforms-map coll] - (let [rf (if (vector? xforms-map) - (apply juxt (map #(% just) xforms-map)) - (apply juxt-map (sequence (comp (by-key (map #(% just))) cat) xforms-map)))] - (rf (clj/reduce rf (rf) coll)))) + Returns a map with the same keyset as xforms-map (or a vector of same size as xforms-map). + Returns a transducer when coll is omitted." + ([xforms-map] + (let [rf (if (vector? xforms-map) + (apply juxt (map #(% just) xforms-map)) + (apply juxt-map (sequence (comp (by-key (map #(% just))) cat) xforms-map)))] + (reduce rf))) + ([xforms-map coll] + (transduce (transjuxt xforms-map) just coll)))