Very good to all, to see if you can help me. I have a problem when I want to remove all the consecutive items from a list that comply with the condition of being an upper case and a lowercase one and returning the rest of the list to me. Example: Given a sequence: "aAbBaa" the result is "aa" or this other example "cCBb" the result is "" I have this implementation:
removerInversos :: secuencia -> secuencia
removerInversos [] = []
removerInversos (x:xs)
| isInverse x cabezaCola == True = cola
| otherwise = x: removerInversos cola
where
cabezaCola = head xs
cola = tail xs
The isInverse
function:
isInverse :: Operador -> Operador -> Bool
isInverse x y = (match x y) && ( ((isUpper x) && (isLower y))|| ((isLower x) && (isUpper y)) )
Function match
:
match :: Operador -> Operador -> Bool
match x y = (toUpper x) == (toUpper y)