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!