Selectively replace multiple instances of a character within a string: Difference between revisions
Content added Content deleted
Line 158:
nthCharsReplaced ruleMap = snd . mapAccumL go M.empty
where
go a c
let i = fromMaybe 0 (M.lookup c a)
in ( M.insert c (succ i) a,
otherChar i c (fromMaybe [] (M.lookup c ruleMap))
)
| otherwise
otherChar :: Int -> Char -> [Maybe Char] -> Char
|