accumArray -package:array

The accumArray function deals with repeated indices in the association list using an accumulating function which combines the values of associations with the same index. For example, given a list of values of some index type, hist produces a histogram of the number of occurrences of each index within a specified range:
hist :: (Ix a, Num b) => (a,a) -> [a] -> Array a b
hist bnds is = accumArray (+) 0 bnds [(i, 1) | i<-is, inRange bnds i]
accumArray is strict in each result of applying the accumulating function, although it is lazy in the initial value. Thus, unlike arrays built with array, accumulated arrays should not in general be recursive.
Create an array by accumulating a list of (index, operand) pairs from a default seed with an operation.