I have a function that takes a substring and a string and finds matching occurrences of the substring in the string and changes matching characters to uppercase. For example:
> upperCase "aaa" "---aaa---"
"---AAA---"
I'd like to use this function, but apply the upperCase operation using several substrings. For example:
> upperCases ["aaa", "bbb", "c"] "d---aaa---c--bbb"
"d---AAA---C--BBB"
What I'm struggling to understand is how I can do this. Here's my best attempt:
upperCases [] st = st
upperCases [x] st = upperCase x st
upperCases (x:xs) st = upperCases xs st
When I use this upperCases function in the example above, I get the following incorrect output:
"d---aaa---C--bbb"
Only the last substring is being changed. What is wrong with this function and I can I write a function to perform the example operation?