countCS :: [Char] -> [(Char, Int)]

I use this

count :: (Ord a, Num b) => [a] -> (a -> b,[(a,b)])
count xs = ( flip (Map.findWithDefault 0) m , Map.assocs m )
    where m = Map.fromListWith (+) $ zip xs $ repeat 1

which returns the frequencies list as well as a query function that I found myself quite often useful.

/BR
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to