Given an original association:
original = <| "a" -> {a1, a2}, "b" -> {b1, b2}, "c" -> {c1, c2} |>
and a set of redistribution rules e.g.
distribution = <|
"a" -> <|"A" -> .5, "B" -> .5|>,
"b" -> <|"C" -> 1|>,
"c" -> <|"C" -> 1|>
|>
How to generate
<|
"A" -> .5{ a1 , a2},
"B" -> .5{ a1, a2},
"C" -> {b1, b2} + {c1, c2}
|>
Original association and the final result are strict but distribution
form can be changed to something that work better with your solution.
I tried
distribution //
KeyValueMap[ Module[{mark}, #2 mark /. mark -> original[#]] & ] //
Merge[Total]
(*mark is there to thread nicely*)
Neat but it is not very readable. Nested Table would be readable but not neat.
Is there something idiomatic and readable?