This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-08
Channels
- # admin-announcements (3)
- # bangalore-clj (3)
- # beginners (21)
- # boot (32)
- # cider (14)
- # clara (2)
- # cljs-dev (19)
- # cljsjs (8)
- # cljsrn (1)
- # clojars (1)
- # clojure (147)
- # clojure-australia (6)
- # clojure-brasil (8)
- # clojure-canada (2)
- # clojure-gamedev (3)
- # clojure-greece (2)
- # clojure-hk (5)
- # clojure-italy (10)
- # clojure-japan (8)
- # clojure-korea (4)
- # clojure-russia (25)
- # clojure-sg (2)
- # clojure-spec (36)
- # clojure-uk (34)
- # clojurescript (88)
- # cursive (157)
- # datomic (6)
- # devcards (1)
- # dirac (1)
- # editors-rus (3)
- # events (2)
- # funcool (1)
- # hoplon (57)
- # jobs (9)
- # lein-figwheel (2)
- # luminus (1)
- # om (156)
- # onyx (93)
- # perun (11)
- # rdf (65)
- # re-frame (36)
- # reagent (17)
- # ring-swagger (3)
- # specter (19)
- # untangled (33)
Hi, I’m trying to solve using Specter the clojure brave and true example of chapter 3 (the one with the hobbit symmetrical body, search 'Pulling It All Together' on http://www.braveclojure.com/do-things/), but I can’t find a way to do it. Can anybody enlighten me ?
My best shot is to transform existing parts, but I didn’t add them to the whole collection :
(transform [ALL needs-matching-part?]
make-matching-part
asym-hobbit-body-parts)
@gphilipp one way to do that is with multi-transform, I think:
(multi-transform [ALL needs-matching-part? (multi-path (terminal identity)
(terminal make-matching-part))]
asym-hobbit-body-parts)
I don't think that would work, it would overwrite the value with the second transformation in multi-path
there might be a way with com.rpl.specter.zipper
here’s something:
(select [ALL keyword? (continue-then-stay (transformed STAY str))] [:a :b :c])
[":a" :a ":b" :b ":c" :c]
(transform [VECTOR-ZIP LEFTMOST (stay-then-continue RIGHT) NODE-SEQ (view set) (collect-one FIRST) (subset #{})] (fn [body-part _] #{(make-matching-part body-part)}) asym-hobbit-body-parts)
#nailedit
so, I have this small path that I’m using in several places: [map? ALL (sp/if-path #(-> % first ks) LAST)]
it’s basically a select-key
(didn’t use (view #(select-key …))
cause it doesn’t work on transforms :(). is this the right way of doing it? if it is, how can I transform it into a nav? my goal is to call (key-selector ks)
inside a path
There might be a way to do it with multi-path
.
Or submap
@caio yeah that's exactly submap
(https://github.com/nathanmarz/specter/wiki/List-of-Navigators#submap)
well, that was easy. thanks again @codonnell