Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.Char
- import Data.List
- import qualified Data.Set as Set
- vowel x = elem x "aeiou"
- toPigLatin :: String -> String
- toPigLatin word
- | vowel (head word) = word ++ "ay"
- | otherwise = let (v, c) = span (not . vowel) word in
- if c == "" then word
- else c ++ v ++ "ay"
- pigExists :: String -> Set.Set String -> Bool
- pigExists word set = Set.member (toPigLatin word) set
- main :: IO ()
- main = do
- allWords <- (((map.map) toLower) . words) <$> readFile "/tmp/linuxwords" --https://users.cs.duke.edu/~ola/ap/linuxwords
- let pigHits = filter (\word -> pigExists word (Set.fromList allWords)) allWords
- print $ pigHits
Add Comment
Please, Sign In to add comment