I'm trying to replace a string with another string in Haskell. Here's the code that I have so far, but it doesn't exactly work.
replace :: [Char] -> [Char]
replace [] = []
replace (h:t) =
if h == "W"
then "VV" : replace t
else h : replace t
I want to be able to accomplish this for example: if the string is "HELLO WORLD", the result should be "HELLO VVORLD". I think words/unwords would be helpful, but not exactly sure how to implement it.
[Char], which means that it can only takeChars and nothing else. Note the types of(:)too. Yeah, Haskell's a lot of fun! :-)