This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-20
Channels
- # arachne (4)
- # bangalore-clj (1)
- # beginners (38)
- # boot (182)
- # cider (21)
- # cljs-dev (9)
- # clojars (5)
- # clojure (229)
- # clojure-austin (1)
- # clojure-berlin (1)
- # clojure-czech (3)
- # clojure-dusseldorf (3)
- # clojure-ireland (5)
- # clojure-italy (4)
- # clojure-russia (33)
- # clojure-spec (73)
- # clojure-taiwan (6)
- # clojure-uk (22)
- # clojure-ukraine (1)
- # clojurescript (80)
- # core-async (26)
- # cursive (3)
- # datascript (20)
- # datomic (9)
- # defnpodcast (8)
- # editors (4)
- # emacs (7)
- # garden (41)
- # hoplon (2)
- # java (1)
- # lambdaisland (2)
- # lein-figwheel (1)
- # leiningen (5)
- # luminus (4)
- # lumo (36)
- # off-topic (4)
- # om (21)
- # onyx (1)
- # pedestal (33)
- # re-frame (33)
- # ring-swagger (70)
- # spacemacs (26)
- # specter (7)
- # sql (6)
- # timbre (2)
- # untangled (12)
- # vim (3)
- # yada (1)
Follow up question about generating paths of keys from embedded maps. My leaf values are sequences of numbers. If I use the first solution you gave, and don't strip out the values using butlast
, I almost get what I want:
(select (recursive-path [] p
(if-path map?
[ALL (collect-one FIRST) LAST p]
STAY))
{:a1 {:b1 [1 2 3]
:b2 [3 4 5]}
:a2 {:b2 [6 7 8]}})
;=> [[:a1 :b1 [1 2 3]] [:a1 :b2 [3 4 5]] [:a2 :b2 [6 7 8]]]
What I want is [[:a1 :b1 1 2 3] [:a1 :b2 3 4 5] [:a2 :b2 6 7 8]]
. I've been trying to figure out how to do this in specter. Of course it's easy to fix in core Clojure afterwards. If I replace STAY
with ALL
, I get a separate path vector for each of the numbers in the leaf vectors. Other things I've tried either produce one of these two results, or error. Thanks again for any help.
@mars0i for that it's best to just fix it after the selection, with regular clojure or a transform
call
it's possible to do it in one path with specter's zipper integration, but it won't be particularly elegant
thought i’d share a satisfying solution i was just able to rattle off for extracting some information using specter (spr/select [:Resources spr/ALL (spr/collect spr/FIRST) spr/LAST :Properties :ContainerDefinitions spr/ALL :Environment spr/ALL (spr/selected? :Name #(= % "REFERENCE_DATASET")) :Value] t)
(i’m on an old version still)