Advertisement
Guest User

Untitled

a guest
Feb 13th, 2012
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import System.Environment                                                                                                                                                                            
  2. import Control.Monad
  3. import Data.Set
  4. import Char
  5.  
  6. main = do
  7.     [s] <- getArgs
  8.     f   <- readFile "/usr/share/dict/words"
  9.     g   <- readFile s
  10.     let dict = fromList (lines f) in
  11.       mapM_ (spell dict) (words g)
  12.  
  13. alphabet = fromList ( ['a'..'z'] ++ ['\''] )
  14.  
  15. clean :: String -> String
  16. clean [] = []
  17. clean (c:cs) | member cl alphabet = cl : clean cs
  18.              | otherwise          = clean cs
  19.             where cl = toLower c
  20.  
  21. incorrect d w = notMember (clean w) d
  22.  
  23. spell d w = when (incorrect d w) (putStrLn w)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement