Re:Functional-navigational programming in Clojure with Specter
by nathanmarz on Tuesday September 29, 2015 @11:50AM
(#10297158)
It sounds like you're looking for the "walk" selector, which comes with Specter:
(select (walker number?) {2 [1 2 [6 7]] :a 4 :c {:a 1 :d [2 nil]}})
=> [2 1 2 1 2 6 7 4]
I've personally found this to be a use case that comes up infrequently.
I'd love to be able to describe features of a data structure and have all qualifying elements be transformed, without my having to tell the select function how to get to those data structures in the first place; just hand it a data structure, and have it grovel through looking for matching subsets, then transforming them as desired.
Sort of like a grammar/DSL for Clojure data structures, without having to be specified from the basic character level up.