Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import System.IO (getContents)
import Data.Map (fromListWith, toList)
import Data.List (sortBy)
import Data.Ord (comparing)
import Data.Char (toLower, isLetter)
countedWords = toList . fromListWith (+) . map (flip (,) 1)
showTuple (item, count) = "word: " ++ item ++ " count: " ++ show count
normalized = map toLower . filter isLetter
main = getContents >>= mapM_ (putStrLn . showTuple)
. sortBy (flip (comparing snd))
. countedWords
. map normalized
. words
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.