module Exercise04 where {-WETT-} xmlLight :: String -> Bool xmlLight xs = checkTags [] $ map (wordsMapHelper . lineMapHelper '>') $ lineMapHelper '<' $ "test>" ++ xs ++ "" wordsMapHelper :: [String] -> String wordsMapHelper xss = if length xss == 2 && length word == 1 then head word else "/" where word = words $ head xss lineMapHelper :: Char -> String -> [String] lineMapHelper c xs = lines $ map (\x -> if x == c then '\n' else x) $ xs ++ "end" checkTags :: [String] -> [String] -> Bool checkTags ass [] = null ass checkTags ass (zs:zss) = '/' `notElem` zs && checkTags (zs:ass) zss || not (null ass) && tail zs == head ass && checkTags (tail ass) zss {-TTEW-}