Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- The app reads text from stdin, picks words that are four or more characters
- -- long and removes non-initial vowels from them thus making words shorter but
- -- still in may cases comprehensible. All characters apart from letters and
- -- spaces are removed, spaces are replaced with underscores, uppercase letters
- -- are made lowercase. This sentence, processed by the app, looks like this:
- -- ths_sntnc_prcssd_by_the_app_lks_lk_ths
- import System.Exit (die)
- import Data.Char (toLower)
- import Data.List (intercalate)
- main :: IO ()
- main = do
- input <- getContents
- if null input
- then die "No input!"
- else putStr $
- intercalate "_" $
- map removeVowelsInLongWords $
- words $ removeInvalidChars $ map toLower input
- removeInvalidChars :: String -> String
- removeInvalidChars = filter (`elem` ['a' .. 'z'] ++ " ")
- removeVowelsInLongWords :: String -> String
- removeVowelsInLongWords word
- | length word < 4 = word
- | otherwise = revomeVowels word
- where
- revomeVowels [] = []
- revomeVowels (x:xs) = x : filter (not . (`elem` "aeiouy")) xs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement