This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-26
Channels
- # announcements (4)
- # babashka (8)
- # beginners (75)
- # calva (26)
- # cider (33)
- # circleci (5)
- # clojure (36)
- # clojure-dev (2)
- # clojure-europe (25)
- # clojure-nl (4)
- # clojure-spec (38)
- # clojure-uk (47)
- # clojurescript (15)
- # cloverage (2)
- # conjure (64)
- # core-async (41)
- # cursive (13)
- # data-science (2)
- # datalog (16)
- # datascript (22)
- # datomic (9)
- # duct (2)
- # emacs (81)
- # figwheel-main (1)
- # fulcro (4)
- # jobs (2)
- # jobs-discuss (29)
- # kaocha (3)
- # meander (11)
- # membrane (21)
- # off-topic (1)
- # portal (1)
- # re-frame (1)
- # reitit (1)
- # releases (2)
- # remote-jobs (31)
- # shadow-cljs (26)
- # specter (5)
- # sql (26)
- # tools-deps (19)
- # vim (12)
im trying to make this:
(def cells {:4 {:2 {:text "fred", :datatype nil}}, :5 {:4 {:text "bob", :datatype nil}}, :8 {:1 {:text "fred", :datatype nil}})
become:
[{:row 5 :col 5 :text "bob" :datattype nil}]
so far i have this nav:
(defn bob? [x] (= (:text x) "bob"))
(s/select [s/MAP-VALS s/MAP-VALS bob?] cells)
which gives:
[{:text "bob", :datatype nil}
i can't seem to figure out collect-*, putval and friends well enough to grab the keys along the path, appreciate any guidance anybody might have thank you
Does this help?
(sp/select [ALL (sp/collect-one [FIRST]) LAST
ALL (sp/collect-one [FIRST]) LAST
bob?] cells)
I use ALL (sp/collect-one [FIRST]) LAST
pattern to collect keys and continue on traversing.
You get [[:5 :4 {:text "bob", :datatype nil}]]
which then i then guess you have to (map)
to something to integrate into the the map at the third slot.
YES thank you, you gave me a great insight there - by using MAP-VALS i was effectively stripping off access to the keys i needed to collect - i like the way you indented everything too - helps make clear how it works. thank you!