module Exercise04 where {-WETT-} import Data.List xmlLight :: String -> Bool xmlLight = xmlAux [] xmlAux :: [String] -> String -> Bool xmlAux yss ('<':xs) | '>' `notElem` xs = False | '/' /= head xs = xmlAux (tag : yss) rest | ' ' `elem` strip tag || '<' `elem` tag || null yss = False | otherwise = strip (tail tag) == strip (head yss) && xmlAux (tail yss) rest where i = head (elemIndices '>' xs) tag = take i xs rest = drop (i+1) xs strip zs = dropWhile (== ' ') $ reverse zs xmlAux yss (x:xs) = '>' /= x && xmlAux yss xs xmlAux yss [] = null yss {-TTEW-}