This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-14
Channels
- # ai (24)
- # announcements (36)
- # babashka (15)
- # babashka-sci-dev (8)
- # beginners (18)
- # biff (4)
- # calva (24)
- # cider (13)
- # clj-kondo (1)
- # clj-on-windows (2)
- # clojars (15)
- # clojure (120)
- # clojure-dev (13)
- # clojure-europe (69)
- # clojure-nl (1)
- # clojure-norway (8)
- # clojure-uk (2)
- # clojurescript (4)
- # core-logic (2)
- # cursive (6)
- # datomic (193)
- # dev-tooling (4)
- # emacs (1)
- # hyperfiddle (57)
- # lsp (56)
- # malli (11)
- # missionary (15)
- # nbb (61)
- # off-topic (8)
- # polylith (8)
- # practicalli (2)
- # proletarian (1)
- # reitit (3)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (13)
- # spacemacs (1)
- # specter (2)
- # sql (17)
- # tools-deps (3)
- # vim (38)
Hi I have a parsed yaml file and I want to select a tree where the first map entry contains a key of value x and content of y.
If your selecting a single node (and the tree is sufficiently nested within that node), you can simply select it like this
(select-one [ALL (selected? map? :key (pred= val))] collection)
If you need to filter out the other attribues of nested nodes:
I don’t have a good intuition of the recursive paths, but it can look something like this:
(select
(recursive-path [] p
(if-path my-predicate?
(continue-then-stay :mykeyword ALL p)))
collection)
That only selects the tree of keyword :mykeyword
. You would probably l need to modify the continue path.
Docs: https://github.com/redplanetlabs/specter/wiki/Using-Specter-Recursively
You can check out some interesting implementations in the navigator collection libraries that have been shared.
https://clojars.org/search?q=specter