Selectively replace multiple instances of a character within a string: Difference between revisions
Selectively replace multiple instances of a character within a string (view source)
Revision as of 19:45, 28 July 2022
, 1 year ago→{{header|Haskell}}
m (→{{header|ALGOL 68}}: typo) |
|||
Line 192:
nthCharsReplaced :: M.Map Char [Maybe Char] -> String -> String
nthCharsReplaced ruleMap = snd . mapAccumL go
where
go a c =
case M.lookup c
Nothing -> (a, c)
Just ds ->
( M.adjust
fromMaybe c
)
|