Skip to content

Instantly share code, notes, and snippets.

@monzou
Created June 17, 2012 02:21
Show Gist options
  • Save monzou/2943174 to your computer and use it in GitHub Desktop.
Save monzou/2943174 to your computer and use it in GitHub Desktop.
word-count @ Haskell
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