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.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to