You can also do something like this instead of the case statement (this is using GHCI).Prelude> let exclude = ['a', 'e', 'i', 'o', 'u']Prelude> let f excl letter | letter `elem` excl = 'x' | otherwise = letterPrelude> map (f exclude) "hello""hxllx"Rob ZiembaOn Sun, Oct 4, 2009 at 9:10 AM, Colin Paul Adams <colin@colina.demon.co.uk> wrote:
>>>>> "John" == John Moore <john.moore54@gmail.com> writes:
John> Hi, I am now writing a function that replaces vowels with
John> the letter x. eg.put in a string "help" and out comes hxlp.
John> I tried this:
John> f x = case x of
John> {'a' -> 'x';'e' -> 'x';'i' -> 'x';'o' -> 'x';'u' ->
John> 'x';_ -> x}
John> but this wont work on strings, only on the individual
John> letters. Any direction would be very welcome.
You need to call
map f "whatever"
where f is your function for replacing a character (as above).
--
Colin Adams
Preston Lancashire
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners