Created
June 5, 2012 14:11
-
-
Save liamoc/2875241 to your computer and use it in GitHub Desktop.
Fun pointless style
This file contains 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 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