17 Oct
2007
17 Oct
'07
7:19 p.m.
On 10/17/07, Peter Verswyvelen <bf3@telenet.be> 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