Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Recursive Character Search and Destroy

Name: Anonymous 2007-05-11 16:50 ID:tCgeez6Q

I receive a string, and I want to remove any 'a', 'b' and 'c' characters, in a recursive way.

How do I do this in C and Java?

Thanks

Name: Anonymous 2007-05-16 5:16 ID:ytzgLpDV

I'm surprised noone has done a Haskell version yet. Oh well, here you go:
remove a b c = filter (/= a) . filter (/= b) . filter (/= c)
It would of course be trivial to have it take a list of items to remove instead of just 3. Also note that thanks to Haskell's generic-by-default-ness this works on lists of any type, not just strings.

Haskell wins once again.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List