
Hi John,
Can you tell us what your function is supposed to do? It appears to be some
kind of search-and-replace for strings. What is the relationship between
'findStr', 'replaceStrList' and 'myText'?
2013/5/8 John
Hello All,
I'm in a big trouble with incrementation of a counter in this code. It doesn't increment.
Could you please tell me where the problem ist and how can I solve it?
replaceBasedIdx :: String -> [String] -> String -> String replaceBasedIdx findStr replaceStrList myText = replaceBasedIdxSub findStr replaceStrList myText 0
replaceBasedIdxSub :: String -> [String] -> String -> Int -> String replaceBasedIdxSub findStr replaceStrList myText counter = loop myText where loop [] = [] loop myText = let (prefix, rest) = splitAt n myText in if findStr == prefix -- found an occurrence? then (replaceStrList !! (counter+1)) ++ loop rest -- yes: replace it
else head myText : loop (tail myText) -- no: keep looking n = length findStr
Thank you very mutch!
Greetings!