[Haskell-beginners] string instead of char

Colin Paul Adams colin at colina.demon.co.uk
Sun Oct 4 12:10:39 EDT 2009

>>>>> "John" == John Moore <john.moore54 at 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

More information about the Beginners mailing list