Created
June 17, 2012 02:21
-
-
Save monzou/2943174 to your computer and use it in GitHub Desktop.
word-count @ Haskell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
main = print $ wordCount "boom bip bip boom bang boom bang" | |
wordCount :: String -> [(String, Int)] | |
wordCount = map (\w -> (head w, length w)) . group . sort . words |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment