This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-08
Channels
- # admin-announcements (1)
- # arachne (3)
- # beginners (17)
- # boot (36)
- # bristol-clojurians (1)
- # cider (4)
- # clara (10)
- # cljsjs (11)
- # cljsrn (20)
- # clojure (134)
- # clojure-austin (2)
- # clojure-boston (1)
- # clojure-czech (1)
- # clojure-greece (128)
- # clojure-norway (1)
- # clojure-romania (1)
- # clojure-russia (17)
- # clojure-spec (106)
- # clojure-sweden (1)
- # clojure-taiwan (1)
- # clojure-uk (41)
- # clojurescript (122)
- # component (4)
- # cursive (1)
- # datomic (34)
- # editors (57)
- # emacs (12)
- # events (5)
- # hoplon (18)
- # instaparse (1)
- # jobs (9)
- # keechma (9)
- # lein-figwheel (3)
- # luminus (1)
- # om (47)
- # onyx (31)
- # proton (2)
- # re-frame (7)
- # reagent (3)
- # rethinkdb (1)
- # specter (25)
- # sql (2)
- # untangled (21)
- # yada (1)
Started using specter as well ;)
so first question 😄 let's say I have a map indexed by a long, but i don't care about that, I want to navigate to the value
the [sp/ALL sp/MAP-VALS ]
path navigates all the keys first, then values
I'd like to skip keys if possible...
easier to understand if you show the input/output you're looking for
{:handles {"booma" {:business {:id 3, :name "", :twitter-handle "booma"}, :sente-uids ["e8a6a187-1e6b-41d1-aa93-d0912a290f49" "arsassa-1e6b-41d1-aa93-d0912a290f49"]}
"my-handle" {:business {:id 5, :name "Business", :twitter-handle "my-handle"}, :sente-uids ["artart27-1e6b-41d1-aa93-d091arsasr49"]}}}
I'd like to fetch the inner maps, skipping the string key
there's a lot of inner maps
so you want the maps that have :business key?
you are right, skip to {:business .....}
(select [:handles MAP-VALS] data)
can also do (select [:handles ALL LAST] data)
but the former is more efficient
oh cool, yes it works, so I needed no ALL
in my code above...
I so like the fact that you can transform in one go all the things you need to...thanks a lot for the help and the lib
sure thing
don't want to take too much of your time as I can check the samples, but I saw that you can collect data while you descend the data structure, in my case it would be really handy to carry the {"booma" {...} "my-handle" {...}}
map in the transform
...is it feasible with collect
?
(transform [:handles VAL MAP-VALS ] ...
oh cool awesome
VAL
is same as (collect-one STAY)
perfect that is exactly what I need 😉
my first specter transformation 🙂
(defn deregister-uid [state uid]
(->> state
(spm/transform (sp/multi-path :uids
[:handles sp/MAP-VALS :sente-uids]
[:businesses sp/MAP-VALS :sente-uids])
#(cond
(map? %) (dissoc % uid)
(vector? %) (vec (remove #{uid} %))
:else %))))