module As where import Data.Char isSubseqOf :: (Eq a) => [a] -> [a] -> Bool isSubseqOf [] _ = True isSubseqOf _ [] = False isSubseqOf a@(x:xs) (y:ys) | x == y = isSubseqOf xs ys | otherwise = isSubseqOf a ys capitalize :: Char -> Char capitalize x | (ord x) >= (ord 'a') = (chr ((ord x) - 32)) | otherwise = x capitalizeWords :: String -> [(String, String)] capitalizeWords text = map f (words text) where f w@(x:xs) = (w, (capitalize x) : xs) capitalizeWord :: String -> String capitalizeWord (x:xs) = (capitalize x) : xs capitalizeParagraph :: String -> String capitalizeParagraph = it True where it _ [] = [] it _ ('.':xs) = '.' : (it True xs) it y (x:xs) | (ord x) >= (ord 'a') && (ord x) < (ord 'z') && y = (capitalize x) : (it False xs) | otherwise = x : (it y xs)