From 8f9b954a2b2b1d1355151fe27403885acff9b7e9 Mon Sep 17 00:00:00 2001 From: Christophe Grand Date: Tue, 12 Sep 2017 16:27:23 +0200 Subject: [PATCH] 0.9.4: `add x/into-by-key`, shorthand for` (comp (x/by-key ..) (x/into ..))` --- README.md | 4 ++-- project.clj | 2 +- src/net/cgrand/xforms.cljc | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 982806b..ea5ee3c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ More transducers and reducing functions for Clojure(script)! 1-item transducers generally only make sense in the context of a higher-order transducer. * regular ones: `partition` (1 arg), `reductions`, `for`, `take-last`, `drop-last`, `window` and `window-by-time` - * higher-order ones: `by-key`, `multiplex`, `transjuxt`, `partition` (2+ args) + * higher-order ones: `by-key`, `into-by-key`, `multiplex`, `transjuxt`, `partition` (2+ args) * 1-item ones: `reduce`, `into`, `transjuxt`, `last`, `count`, `avg`, `sd`, `min`, `minimum`, `max`, `maximum`, `str` *Reducing functions* (in `net.cgrand.xforms.rfs`): `min`, `minimum`, `max`, `maximum`, `str`, `str!`, `avg`, `sd`, `juxt` and `last`. @@ -21,7 +21,7 @@ Transducing contexts: `transjuxt` (for performing several transductions in a sin Add this dependency to your project: ```clj -[net.cgrand/xforms "0.9.2"] +[net.cgrand/xforms "0.9.4"] ``` ```clj diff --git a/project.clj b/project.clj index ffceeae..4f50d9b 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject net.cgrand/xforms "0.9.3" +(defproject net.cgrand/xforms "0.9.4" :description "Extra transducers for Clojure" :url "https://github.com/cgrand/xforms" :license {:name "Eclipse Public License" diff --git a/src/net/cgrand/xforms.cljc b/src/net/cgrand/xforms.cljc index e51123e..f0b8d4c 100644 --- a/src/net/cgrand/xforms.cljc +++ b/src/net/cgrand/xforms.cljc @@ -278,6 +278,11 @@ acc))) ([acc k v] (self acc #?(:clj (clojure.lang.MapEntry. k v) :cljs [k v]))))))))))) +(defn into-by-key + "A shorthand for the common case (comp (x/by-key ...) (x/into {}))." + [coll & by-key-args] + (comp (apply by-key by-key-args) (into coll))) + (macros/replace [#?(:cljs {(java.util.ArrayDeque. n) (Queue.) .add .enqueue