How to find the frequency of characters in a string in Haskell?

前端 未结 7 1275
谎友^
谎友^ 2020-12-11 15:08

How can I count the frequency of characters in a string and then output them in sort of a table?

For example, if I input the word \"happy\" the result would be

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-11 15:21

    func xs = map (\a -> (head a, length a)) $ group $ sort xs

提交回复
热议问题