Fast Multi-Accumulator Reducers

from blog Aphyr: Posts, | ↗ original
Again with the reductions! I keep writing code which reduces over a collection, keeping track of more than one variable. For instance, here’s one way to find the mean of a collection of integers: (defn mean "A reducer to find the mean of a collection. Accumulators are [sum count] pairs." ([] [0 0]) ([[sum count]] (/ sum count)) ([[sum...