[Haskell-cafe] Incrementation fails
John
knowledge1202 at gmail.com
Wed May 8 06:30:48 CEST 2013
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!
--
View this message in context: http://haskell.1045720.n5.nabble.com/Incrementation-fails-tp5729905.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe
mailing list