Created
May 11, 2015 02:18
-
-
Save iporsut/daef089b28e99da10c7d to your computer and use it in GitHub Desktop.
replace character in string
This file contains hidden or 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
replace xs a b = replace' [] xs | |
where | |
replace' acc [] = acc | |
replace' acc (x:xs) | x == a = replace' (acc ++ [b]) xs | |
| otherwise = replace' (acc ++ [x]) xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment