3 ms·
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]}}) =
by nathanmarz 11y ago
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.
- tel 11y agoWalk shows up quite often in the "uniplate" functionality of Haskell's `lens`. It's really, really useful for handling AST transformations, but depends a bit on laziness here.
- OliverM 11y agoI'm doing a lot of tree transformation stuff at the moment where it comes up a fair bit. Thanks for the pointer, I'll give it a try.