Fork me on GitHub
#specter
<
2020-08-26
>
fredmonroe20:08:03

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 Ko21:08:54

Does this help?

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

❤️ 3
Raymond Ko21:08:43

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

Raymond Ko21:08:53

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.

fredmonroe22:08:20

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!