I wrote:
> When you can assume Ord, the standard solution
> is, as you suggest, something like...

Oops, sorry, doesn't typecheck. Here it is corrected:

> import qualified Data.Map as M
> import Data.List
>
> histogram = M.toList . foldl' (\m x -> M.insertWith' (+) x 1 m) M.empty

> This should work efficiently, with the right amount of laziness, even
> for very large lists.

Stuart's Arrows thing is much nicer when your list is small
enough to be held in memory all at once.

-Yitz
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to