Skip to content

Instantly share code, notes, and snippets.

@liamoc
Created June 5, 2012 14:11
Show Gist options
  • Save liamoc/2875241 to your computer and use it in GitHub Desktop.
Save liamoc/2875241 to your computer and use it in GitHub Desktop.
Fun pointless style
import Control.Applicative
import Data.List
import qualified Data.Map as M
import Control.Arrow ((&&&), (***))
import Data.Char(isAlpha, toLower)
unscramble = curry $ fmap unwords
. uncurry mapM
. ( ( ( fmap head .)
. flip M.lookup
. ($ M.empty)
. foldr (.) id
. (map $ uncurry (M.insertWith (++))
. (sort &&& (:[])))
. filter (all isAlpha)
. lines
. filter (/= '\''))
*** ( map ( sort
. filter isAlpha)
. words
. map toLower))
main = (unscramble <$> readFile "/usr/share/dict/words"
<*> pure "Olny srmat poelpe can raed tihs. I cduol not blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The pheonmneal pweor of the hmuan mnid")
>>= maybe (putStrLn "translation failed") putStrLn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment