Skip to content

Instantly share code, notes, and snippets.

@iporsut
Created May 11, 2015 02:18
Show Gist options
  • Save iporsut/daef089b28e99da10c7d to your computer and use it in GitHub Desktop.
Save iporsut/daef089b28e99da10c7d to your computer and use it in GitHub Desktop.
replace character in string
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