Skip to content

Instantly share code, notes, and snippets.

@dpwiz
Last active December 18, 2015 18:29
Show Gist options
  • Save dpwiz/5826131 to your computer and use it in GitHub Desktop.
Save dpwiz/5826131 to your computer and use it in GitHub Desktop.
http://www.reddit.com/r/programming/
lol
Юникод лол, смотрите, ЮНИКОД!
{-# LANGUAGE TupleSections #-}
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.IO as TL
import Data.Char (isLetter)
import Data.List (sortBy)
import Data.Function (on)
import qualified Data.HashMap.Strict as HM
import System.Environment (getArgs)
collect = sortBy (flip compare `on` snd)
. HM.toList
. HM.fromListWith (+)
. map (,1)
. filter (not . TL.null)
. TL.split (not . isLetter)
. TL.toLower
display (word, count) = do
TL.putStr word
putStr ": "
print count
main = do
[fname, count] <- getArgs
text <- TL.readFile fname
mapM_ display $ take (read count) (collect text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment