added example of if-path to README

This commit is contained in:
Nathan Marz 2015-06-19 14:21:52 -04:00
parent c677486b7b
commit 298f031adb

View file

@ -188,6 +188,15 @@ user> (setval [ALL
[[1 2 3 4 5 6 :c :d] [7 0 -1] [8 8 :c :d] []] [[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 # Future work
- Make it possible to parallelize selects/updates - Make it possible to parallelize selects/updates
- Any connection to transducers? - Any connection to transducers?