From 85e15d00a811ef07e648a3ddc2165ef4ca6671b8 Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Thu, 21 Sep 2017 08:47:20 -0400 Subject: [PATCH] Add blog example. --- List-of-Macros.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/List-of-Macros.md b/List-of-Macros.md index a347a64..d472b19 100644 --- a/List-of-Macros.md +++ b/List-of-Macros.md @@ -273,6 +273,23 @@ _Added in 1.0.0_ Returns a transducer that traverses over each element with the given path. +Many common transducer use cases can be expressed more elegantly with traverse-all: + +```clojure +;; Using Vanilla Clojure +(transduce + (comp (map :a) (mapcat identity) (filter odd?)) + + + [{:a [1 2]} {:a [3]} {:a [4 5]}]) +;; => 9 + +;; The same logic expressed with Specter +(transduce + (traverse-all [:a ALL odd?]) + + + [{:a [1 2]} {:a [3]} {:a [4 5]}]) +``` + # Path Macros ## declarepath