I'm using meander to scan the results of a regression test execution. I'd like to report the count of successful test executions. My strategy is to filter for successes and then somehow group them to count but I can't figure out how to group within meander. Currently, I have:
(m/search regression-suite
(m/and
(m/scan {:regression-test-success? true})
!success-test-records
(m/let [?count (count !success-test-records)]))
(count !success-test-records))
This is obviously wrong and I think I understand why but there's something about memory variables that I'm missing...m/gather
can do that @mark340
(m/gather {:regression-test-success? true :as !success-test-records} ?count)
Hmm… I’m trying that out and am surprised its not working.
Oh wait, whoops.
Made a typo.
(let [data (map hash-map
(repeat :regression-test-success?)
(cycle [true false]))
regression-suite (take 10 data)]
(m/find regression-suite
(m/gather {:regression-test-success? true
:as !success-test-records}
?count)
[!success-test-records ?count]))
;; =>
[[{:regression-test-success? true}
{:regression-test-success? true}
{:regression-test-success? true}
{:regression-test-success? true}
{:regression-test-success? true}]
5]
search
will return more results than you want for this case.
Also, I thought we had a docstring for gather
too. 😕
I can write one tonight.
This is just a hot-take, without ever seeing gather
before, but I find it odd that :as !name
is included in the same map as the pattern. Am I reading that right?
@d4hines Yes, you’re reading that correctly, its to have parity with the familiar :as
from clojure destructuring. We plan to make that a qualified keyword in zeta
, however.
I suppose we could have ::m/as
be thing for epsilon
as well but I’m not a big fan of having two keywords.
Ok, that makes more sense. I wasn't making the connection to destructuring, but with that in context it makes more sense.
I agree it should be a namespaced keyword in another version.
I also agree supporting two keywords in a single version isn't worth it.
Thanks for pointer to gather! I figured that doc entries without doc strings were internal functions.
We have (to the best of my knowledge) hidden the internal functions from showing up the docs.
Good to know. Thx!