Created
April 5, 2015 21:05
-
-
Save letsbreelhere/9640249252a793e60b08 to your computer and use it in GitHub Desktop.
Escape.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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