Histograms

Konrad Hinsen hinsen@cnrs-orleans.fr
Wed, 3 Sep 2003 15:13:30 +0200


How would one best (read: most efficiently) create a histogram in Haskell=
?=20
More precisely, given a list of integers in a known range, I want a count=
 of=20
how often any given number occurs.

In imperative languages this would be done by iterating over the list and=
=20
updating the count for the element under consideration. Without updatable=
=20
data structures, the most straightforward solution I can think of would s=
tart=20
by sorting the list, but for a long list that is very inefficient.

Any suggestions?

Konrad.