Moises Posted August 6, 2020 at 07:08 PM Report Share #618993 Posted August 6, 2020 at 07:08 PM A função duplicarFold :: String -> String repete duas vezes cada vogal (letras 'a', 'e', 'i', 'o', 'u' minúsculas ou maiúsculas) numa cadeia de carateres; os outros carateres devem ficar inalterados. Por exemplo, duplicar "Ola, mundo!"== "OOlaa, muundoo!" Da forma que fiz não esta funcionando: duplicarFold :: String -> String duplicarFold xs = foldr (\x acc-> if elem x vogais then else ) [] xs where vogais = "aeiouAEIOU" Moises Link to comment Share on other sites More sharing options...
Baderous Posted September 3, 2020 at 09:59 PM Report Share #619271 Posted September 3, 2020 at 09:59 PM Está praticamente feito, só te falta preencher o then e o else. No then apenas tens de repetir o x na String e juntar esse 2 caracteres ao acc. duplicarFold :: String -> String duplicarFold s = foldr (\x ss -> if isVowel x then x:x:ss else x:ss) [] s where isVowel x = elem x "aeiouAEIOU" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now