DL
Size: a a a
DL
PG
A
A
DL
(defn distribute [amount distribution]
(first
(reduce-kv
(fn [[total-amount total-weight] key weight]
(if (= total-weight 0)
[total-amount 0]
(let [amount (/ (* total-amount weight) total-weight)
used (key amount)]
[(- total-amount used) (- total-weight weight)])))
[amount (reduce + (vals distribution))]
distribution)))
PG
A
PG
A
DL
A
DL
A
A
DL
A
DL
A
A
DL
{:children [] :weight 3 :handler handle-fn}
?