The second argument may be either a character or a string; the let builds a list of characters to be deleted. Then the target string is converted to a list of characters, each is filtered according to the list of characters to be deleted, and the remaining characters are converted back to a string. The for is typical of C, the higher-order function filter is typical of Scheme. I’m biased, but I think the Scheme version is simpler because it doesn’t require the auxiliary variables i and j, which can both be a source of error. Here’s the function in action, both ways:

@matthew Your MonadPlus suggestion made me wonder what was the “most general” type I could give it. But then I got lost in a maze of twisty little typeclasses (Foldable, Alternative, etc.) and now I will just go to bed… :-)