This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-05
Channels
- # aws (1)
- # beginners (57)
- # boot (3)
- # cider (6)
- # clara (49)
- # cljs-dev (47)
- # cljsjs (23)
- # clojure (144)
- # clojure-dev (2)
- # clojure-finland (1)
- # clojure-germany (1)
- # clojure-sg (1)
- # clojure-spec (25)
- # clojure-uk (245)
- # clojurescript (39)
- # core-async (3)
- # cursive (6)
- # datomic (117)
- # emacs (3)
- # fulcro (6)
- # hoplon (10)
- # jobs (7)
- # juxt (5)
- # leiningen (11)
- # om (27)
- # pedestal (4)
- # perun (2)
- # re-frame (22)
- # reagent (35)
- # ring-swagger (11)
- # shadow-cljs (333)
- # spacemacs (10)
- # specter (10)
- # sql (20)
- # vim (8)
Can I use specter
to get the path of some deeply nested key using a predicate?
Say I want the path to the last value that’s brown
here:
{:a "foo" :b :_ :c {:d "brown" :e "bar"} :f [{:g "pale" :h "brown" :i {:j "ale" :k [{:l "brown"} {:l "brown"}]}}]}
@hkjels yes, you use recursive-path
and collect-one
a related example here: https://github.com/nathanmarz/specter/wiki/Using-Specter-Recursively#find-the-index-route-of-a-value-within-a-data-structure
@nathanmarz thanks! I’ll give that a shot Looks like a really good lib
@nathanmarz: Just pushed a new version of PR with mutual recursion and the building blocks we've been working on - could use an assist coming up with a better example for mutually recursive paths
@michaelwfogleman I only ever made a mutually recursive path once... and it's way too involved to use as an example
I think just showing the basics of how mutually recursive paths would be structured is sufficient
speaking of examples, if anyone has any interesting ones that they want me to turn into a specter koan, just open an issue and paste it in https://github.com/gdeer81/specter-koans/issues
@nathanmarz In that case, the PR should be either pretty close or good to go 🙂