specter

Latest version: 1.1.3
fredmonroe 2020-08-26T20:45:03.004600Z

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

Raymond Ko 2020-08-26T21:55:54.005100Z

Does this help?

(sp/select [ALL (sp/collect-one [FIRST]) LAST
              ALL (sp/collect-one [FIRST]) LAST
              bob?] cells)

❤️ 1
Raymond Ko 2020-08-26T21:56:43.006100Z

I use ALL (sp/collect-one [FIRST]) LAST pattern to collect keys and continue on traversing.

Raymond Ko 2020-08-26T21:57:53.007200Z

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.

fredmonroe 2020-08-26T22:17:20.009100Z

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!