On 10/17/07, Peter Verswyvelen <[EMAIL PROTECTED]> wrote:
> So in that case, the result should be a list of ordered pairs like:
> [("egg", 2), ("cheese", 1)]. Or a pair of two lists, like (["egg",
> "cheese"), (2,1)]. Otherwise you would not know which frequency belongs
> to which element?

> However, I suspect the experts here will be able to make that much
> shorter and more efficient (maybe using Data.Map?)


  import Control.Arrow
  import Data.List

  freqs = map (head &&& length) . group . sort

I have used this function quite a few times already.


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

Reply via email to