In an imperative language like Python, I'd use a dictionary as an accumulator - something likefor el in input: accums[i] = accums.get(i, 0) + 1
Haskell has efficient dictionary structures too, e.g. Data.Map
List.foldl' (\m x-> Map.insertWith' (+) x 1 m) Map.empty
Regards,
Malcolm
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe
