[Haskell-cafe] How to speed things up

Dmitry Vyal akamaus at gmail.com
Thu Apr 28 10:51:55 EDT 2005

Hello everybody.

I have a long list consisted of a small number (about a dozen) of 
elements repeating in random pattern. I know all the possible elements.
I need to count number of occurences of each particular element and to 
do i quickly.

    For example
quick_func Eq a => [a] -> [(a,Int)]
quick_func [1,2,3,1,2,9,1,9] == [(1,3),(2,2),(3,1),(9,2)]

According to profiler this function is the bottle-neck in my sluggish 
program so I really need to speed it up.

Any proposals?

More information about the Haskell-Cafe mailing list