<div dir="ltr">Or instead of ['a', 'e', 'i', 'o', 'u'] use "aeiou". However, I think the case statement, while my verbose, is also clearer. But that's purely a style choice.<br>
<br>Michael<br><br><div class="gmail_quote">On Sun, Oct 4, 2009 at 8:55 PM, Robert Ziemba <span dir="ltr"><<a href="mailto:rziemba@gmail.com">rziemba@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
You can also do something like this instead of the case statement (this is using GHCI). <div><br></div><div><div>Prelude> let exclude = ['a', 'e', 'i', 'o', 'u']</div><div><div>
Prelude> let f excl letter | letter `elem` excl = 'x' | otherwise = letter</div>
<div>Prelude> map (f exclude) "hello"</div><div>"hxllx"</div></div><div><br></div><div>Rob Ziemba</div></div><div><div></div><div class="h5"><div><br><div class="gmail_quote">On Sun, Oct 4, 2009 at 9:10 AM, Colin Paul Adams <span dir="ltr"><<a href="mailto:colin@colina.demon.co.uk" target="_blank">colin@colina.demon.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">>>>>> "John" == John Moore <<a href="mailto:john.moore54@gmail.com" target="_blank">john.moore54@gmail.com</a>> writes:<br>
<br>
John> Hi, I am now writing a function that replaces vowels with<br>
John> the letter x. eg.put in a string "help" and out comes hxlp.<br>
John> I tried this:<br>
<br>
John> f x = case x of<br>
<br>
John> {'a' -> 'x';'e' -> 'x';'i' -> 'x';'o' -> 'x';'u' -><br>
John> 'x';_ -> x}<br>
<br>
John> but this wont work on strings, only on the individual<br>
John> letters. Any direction would be very welcome.<br>
<br>
You need to call<br>
<br>
map f "whatever"<br>
<br>
where f is your function for replacing a character (as above).<br>
<font color="#888888">--<br>
Colin Adams<br>
Preston Lancashire<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</font></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>