Replies: 2 comments 1 reply
-
Here's what I came up with. (def input
[{:id 1
:datapoints {[:a1 :b1 :c1 :d1] [1 1 0 0]
[:a1 :b2 :c1 :d1] [1 1 1 1]
[:a1 :b2 :c1 :d2] [1 0 0 0]}}
{:id 2
:datapoints {[:a1 :b1 :c1 :d1] [1 1 0 0]
[:a1 :b2 :c1 :d1] [1 1 1 1]
[:a1 :b2 :c1 :d2] [1 0 0 0]}}])
(m/rewrite input
[{:id ?id & ?rest-map} & ?rest-vector]
[{:id ?id :figures (m/cata ?rest-map)} & (m/cata ?rest-vector)]
(m/with [%entry [[_ ?k1 _ !k2] [!v & _]]]
{:datapoints (m/seqable %entry . (m/or %entry !other-entry) ...)})
{?k1 {& [[!k2 !v] ...]} & (m/cata {:datapoints {& [!other-entry ...]}})}
_
{})
;; =>
[{:id 1, :figures {:b2 {:d1 1, :d2 1}, :b1 {:d1 1}}}
{:id 2, :figures {:b2 {:d1 1, :d2 1}, :b1 {:d1 1}}}] |
Beta Was this translation helpful? Give feedback.
1 reply
-
Thanks for taking this one apart! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey, I've been trying all morning to figure this one out:
Normally I'd do this:
but I wanted to try this out with meander. I got this working:
But how do I get it to recursively merge the maps with the same
?id
? I tried playing around withm/cata
but to no avail. Thanks!Beta Was this translation helpful? Give feedback.
All reactions