From 298f031adb1cfdc13c0d9fa9cfbbb5da13c41b58 Mon Sep 17 00:00:00 2001 From: Nathan Marz Date: Fri, 19 Jun 2015 14:21:52 -0400 Subject: [PATCH] added example of if-path to README --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 68af581..89a2c00 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,15 @@ user> (setval [ALL [[1 2 3 4 5 6 :c :d] [7 0 -1] [8 8 :c :d] []] ``` +For every map in a sequence, increment :c if :a is even and :d if :a is odd: + +```clojure +user> (update [ALL (if-path [:a even?] :c :d)] + inc + [{:a 2 :c 3 :d 4} {:a 4 :c 5} {:a -1 :c 1 :d 1}]) +[{:c 4, :d 4, :a 2} {:c 6, :a 4} {:c 1, :d 2, :a -1}] +``` + # Future work - Make it possible to parallelize selects/updates - Any connection to transducers?