Trying to up my meander game.:
(m/rewrite {:g1 [{:k :a :v 1} {:k :b :v 2}]
:g2 [{:k :b :v 2} {:k :a :v 1}]}
(m/and
{:g1 (m/seqable {:k !k :v !v1} ...)
:g2 (m/seqable {:k !k :v !v2} ...)})
[!k (m/app + !v1 !v2) ...])
I'd like the result to be [:a 2 :b 4
but meander is walking the two seqs independently. How do I get a join on :k ?(m/rewrite {:g1 [{:k :a :v 1} {:k :b :v 2}]
:g2 [{:k :b :v 2} {:k :a :v 1} {:k :b :v 3}]}
{:g1 (m/seqable !g1s ...)
:g2 (m/seqable !g2s ...)}
(m/cata [!g1s ... !g2s ...])
[] []
(m/with [%m {:k ?k
:v !v}]
[%m . (m/or %m !not-m) ...])
[?k ~(reduce + !v) & (m/cata [!not-m ...])])
;; =>
[:a 2 :b 7]
There are probably few other ways to do this.
Again, this is another place where the zeta
fold will come in handy.
Thanks!