Here is an example of what I wanted to do.
let b = ["this","is","a","test!"]
"xx" ++ (b!!3)
This will give me "xxtest!"
Basically if the list contains any string with an exclamation mark then "xx" will be added to this specific string. My questions is how to implement this into a correct function.
Currently I got this
replaceElement [] = []
replaceElement (x:xs) =
if '!' `elem` x
then ["xx"] ++ x : replaceElement xs
else x: replaceElement xs
But this function will just add "xx" into list as an element, it won't be added to the specific string in the list. How can I use "xx" ++ (b!!x) where x is the position of the string with an exclamation mark.