Hi a simple question but one that I have struggled to find an answer: I have a vector of maps and I want to return all the maps that contains a map entry that matches a particular value, for example all maps where :lang contains "EN".
@mmer I believe (spr/select [spr/ALL #(= "EN" (:lang %))] v-of-m)
should do it
So obvious when you see it in front of you! Thanks @spieden
@nathanmarz I'm having an interesting issue combining transform
and stay-then-continue
. I'm replacing a map with a string via transform, and then specter seems to try to navigate the new value like it's still a map and I get class java.lang.String cannot be cast to class clojure.lang.Associative
from do-keypath-transform
. Does that sound familiar at all?
I'm confused: isn't that what stay then continue is supposed to do?
how do you want to transform the map if you've already stringified its contents? do you have a more complete toy example?
i'd assume you want postorder there
ugh, sorry, I just read the backlog
Yeah that's what I ended up doing ⬇️
:)
There is another step to this: I have a vector of pairs of vectors. I want to add a value to the first vector based on a property in the second vector. Again a simple use case, and probably has a simple answer
@mmer You'd probably just handle all that inside your transform function
@spieden thanks, I was expecting to be able to pass the first vector to the transform function without having selected it based on the values in the second function.
Ah hrm, well you can pass the whole tuple to the transform based on a value in the second
.. and then just transform the first vector in it and leave the other alone
That makes sense
(spr/transform [spr/ALL #(fn [[_ v2]] (pred? v2)] transform-v1 vs)
Thanks
@nathanmarz Looks like switching to postorder via continue-then-stay
did the trick!
Many thanks for specter, as always -- not sure how I'd accomplish this work I'm doing without it