module Exercise04 where {-WETT-} xmlLight :: String -> Bool xmlLight = aux [] where aux stack [] = null stack aux _ ('>':_) = False aux stack ('<':str) = let tagID = tag str False in last tagID /= '\NUL' && if head str == '/' then not (null stack) && head stack == takeWhile (/= ' ') (tail tagID) && aux (tail stack) (drop (length tagID + 1) str) else aux (takeWhile (/= ' ') tagID : stack) $ drop (length tagID + 1) str aux stack str = aux stack (tail str) tag [] _ = ['\NUL'] tag (s:str) trail | s == ' ' = s : tag str True | s == '>' = [] | s == '<' || trail = ['\NUL'] | otherwise = s : tag str False {-TTEW-} correct :: String correct = "testingtesttest

testing
testtestingtesttest" ++ "

??\n
testing
testtestingtesttest" ++ "

testing
testtestingtest" ++ "test/

testing
test" test :: String test = "dsadasdaelectrichimself905065503.049459highbentadditional"++ "-1620665414.463251solid-781889022.4765396-275187460famous"++ "truth1823565355.52205371234683189combinationgeneralnature"++ "fastnearesteighthaving1791866926congress"++ "1240001800-1110482304size"