Last active
April 21, 2016 19:01
-
-
Save bfabry/dcc2fbb6c21d31718b173026d6bd51c1 to your computer and use it in GitHub Desktop.
How to do stuff in specter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def MAP-VALS (sp/comp-paths sp/ALL sp/LAST)) | |
; increment the values for a list of keys | |
(sp/transform [(apply sp/multi-path [:foo])] inc {:foo 1 :bar 2}) => {:foo 2 :bar 2} | |
;; or | |
(sp/transform [(sp/submap [:foo]) MAP-VALS] inc {:foo 1 :bar 2}) | |
;; play with submaps | |
(sp/select [(submap [:foo :baz])] {:foo 1 :bar 2}) | |
=> [{:foo 1}] | |
(sp/setval [(submap [:bar])] {:barry 1} {:foo 1 :bar 2}) | |
=> {:foo 1, :barry 1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment