Selectively replace multiple instances of a character within a string: Difference between revisions

Content added Content deleted
Line 197: Line 197:
case M.lookup c a of
case M.lookup c a of
Nothing -> (a, c)
Nothing -> (a, c)
Just ds ->
Just [] -> (a, c)
if null ds
Just (d : ds) ->
then (a, c)
( M.insert c ds a,
else
fromMaybe c d
( M.adjust tail c a,
)
fromMaybe c (head ds)
)


--------------------------- TEST -------------------------
--------------------------- TEST -------------------------