This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-02-24
Channels
- # babashka (6)
- # beginners (11)
- # calva (4)
- # clojure (12)
- # clojure-madison (2)
- # clojure-norway (25)
- # clojure-spec (8)
- # clojure-sweden (1)
- # clojurescript (17)
- # datalevin (1)
- # datomic (8)
- # events (5)
- # ghostwheel (1)
- # hyperfiddle (16)
- # off-topic (16)
- # pedestal (1)
- # reagent (6)
- # reitit (1)
- # releases (3)
- # scittle (1)
- # shadow-cljs (5)
- # specter (2)
- # squint (4)
Hello, I am trying to recurse through a structure of vectors and maps. This almost does what I want, however when it finds kmod
, after navigating to it I would like it to "go back" to the map it was found in and also detect krecur
, and continue recur
ing down that path if it's there. Would be great if this were possible with recursive-path
alone, but if there's a different tool for the job I would love to hear it!
(def rmapkeys (s/recursive-path
[kmod krecur] path
(s/cond-path
sequential? [s/ALL path]
#(get % kmod) [kmod]
#(get % krecur) [krecur path])))
(s/select (rmapkeys :a :b) [{:a :A
:b [{:a :THIS}]}
{:b [{:a :AA}]}])
;; actual result: [:A :AA]
;; the result I want: [:A :THIS :AA]
Thanks in advance 🙂