Reputation: 1
I want to make a function that removes a given character from a string. The prototype is: removeChar :: Char -> String -> String I tried to do something like this:
removeChar a x = foldr (++) [] (map (\x -> filter f x) x)
where
f x = elem a x
Upvotes: 0
Views: 169
Reputation: 555
this should be enough, String is nothing but a [Char] so just filter it for that char
removeChar::Char->String->String
removeChar a = filter (/=a)
Upvotes: 1