Sunday, October 12, 2008

Replace a sublist within a list with another list

This is just a very short snippet but someone might find this useful.
It took me a while to figure out how to do this right in haskell. In case you know of a better solution please tell me about it in the comment section.

replaceAll a b c =
concat (intersperse b (splitRegex regex c))
where
regex = Text.Regex.mkRegex a