Skip to content

Instantly share code, notes, and snippets.

@letsbreelhere
Created April 5, 2015 21:05
Show Gist options
  • Save letsbreelhere/9640249252a793e60b08 to your computer and use it in GitHub Desktop.
Save letsbreelhere/9640249252a793e60b08 to your computer and use it in GitHub Desktop.
Escape.hs
escape :: [(Char, String)] -> String -> String
escape = foldr f id
where f (c,s) acc = acc . replaceOne (c,s)
replaceOne (c,s) = concatMap (\x -> if x == c then s else [x])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment