Created
January 11, 2016 18:53
-
-
Save nathanmarz/40f14d693da3d7fa6faf to your computer and use it in GitHub Desktop.
Recursive navigation with Specter
This file contains hidden or 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
(use 'com.rpl.specter) | |
(use 'com.rpl.specter.macros) | |
(defprotocolpath TreeWalker []) | |
(extend-protocolpath TreeWalker | |
Object nil | |
clojure.lang.PersistentVector [ALL TreeWalker]) | |
(select [TreeWalker number?] [:a 1 [2 [[[3]]] :e] [4 5 [6 7]]]) | |
;; => [1 2 3 4 5 6 7] | |
(transform [TreeWalker number?] inc [:a 1 [2 [[[3]]] :e] [4 5 [6 7]]]) | |
;; => [:a 2 [3 [[[4]]] :e] [5 6 [7 8]]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment