Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import System.Environment
- import Data.Char
- import Data.List
- import Data.Maybe
- main = do
- d <- readFile "/usr/share/hunspell/en_US.dic"
- let ws = filter (all (`elem` ['a'..'z'])) $ takeWhile (/='/') <$> lines (map toLower d)
- wc = fromIntegral $ length ws :: Double
- args <- getArgs
- case length args of
- 3 -> let [sx, sy, sz] = args
- (x, y, z) = (read sx, read sy, read sz) :: (Double, Double, Double)
- pick i = let l = round $ (i+90) * (wc-1) / 180
- (c:cs) = ws!!l
- in toUpper c : cs
- in putStrLn $ pick x ++ pick y ++ pick z
- 1 -> let [(cx:cs)] = args
- (cxs,(cy:cs2)) = span (isLower) cs
- (cys,wz ) = span (isLower) cs2
- wx = cx:cxs; wy = cy:cys
- loc w = let i = fromIntegral . fromJust . elemIndex (map toLower w) $ ws
- in show $ i * 180 / (wc-1) - 90
- in putStrLn $ loc wx ++", "++ loc wy ++ ", " ++ loc wz
- otherwise -> putStrLn "You big dummy!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement