> problem = replaceBasedIdx "X" ["b","d","f"] "aXcXeXgX"
> -- "abcdefg*** Exception: Prelude.(!!): index too large
This problem occurs because you never check if 'counter' is a valid
index in the 'replaceStrList'. You can solve it by not using the !!
operator at all. The solution is to also pass '
I stared at the code some more and deduced what I think is the
intented meaning. Occurences of 'findStr' in 'myText' are replaced
with the strings in 'replaceStrList'.
So replaceBasedIdx "X" ["b","d","f"] "aXcXeXg" = "abcdefg"
The reason your counter didn't increment is because it was defined as
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 c