This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-22
Channels
- # architecture (1)
- # aws (3)
- # beginners (78)
- # boot (33)
- # cider (49)
- # cljs-dev (3)
- # clojure (82)
- # clojure-berlin (2)
- # clojure-dusseldorf (14)
- # clojure-gamedev (75)
- # clojure-italy (15)
- # clojure-nl (2)
- # clojure-poland (9)
- # clojure-russia (1)
- # clojure-spec (11)
- # clojure-uk (91)
- # clojurescript (17)
- # core-async (2)
- # cursive (1)
- # data-science (3)
- # datascript (34)
- # datomic (13)
- # docs (2)
- # duct (32)
- # emacs (8)
- # fulcro (95)
- # instaparse (17)
- # jobs (2)
- # jobs-discuss (1)
- # jobs-rus (4)
- # leiningen (1)
- # luminus (1)
- # lumo (4)
- # mount (1)
- # nrepl (1)
- # off-topic (98)
- # onyx (13)
- # portkey (12)
- # re-frame (10)
- # reagent (11)
- # remote-jobs (4)
- # rum (3)
- # shadow-cljs (34)
- # specter (7)
- # sql (1)
- # tools-deps (8)
So I have a map like this: {"2018-05-22" {:A {123 "foo"}}}
. I need to transform "foo"
, but I need to collect some of the map keys (`"2018-05-22"` and :A
) along the way for the transformation function and I can't quite figure out how to do it.
@flowthing How do you need to navigate to "foo"? Recursively?
With MAP-VALS
. Basically, I'm doing something like this:
(specter/transform [specter/MAP-VALS specter/MAP-VALS specter/MAP-VALS] (fn [& args] ,,,) {"2018-05-22" {:A {123 "foo"}}})
And I'm wondering whether I can write the path such that the transformation fn gets "2018-05-22"
and :A
as arguments (in addition to "foo"
).@flowthing yes, you want to make use of collection navigators
(def MAP-VALS+ (path ALL (collect-one FIRST) LAST))
(transform [MAP-VALS+ MAP-VALS+ MAP-VALS]
(fn [k1 k2 v]
[k1 k2 v]
)
{"2018-05-22" {:A {123 "foo"}}})