<div dir="ltr">>If you're really just dealing in words the penalty of a double<br>>reverse isn't as bad as the penalty of having to use REs.<br>
<font color="#888888"><br></font>True, but the penalty of writing and maintaining code that could be much more clearly expressed as an RE may outweigh the performance penalty. If there is not a large performance penalty I would go for the RE rather than have to start writing code backwards ;-)<br>
<br>Regards,<br>Edwin Fine<br><br><div class="gmail_quote">On Sun, Sep 7, 2008 at 2:47 PM, Vance Shipley <span dir="ltr"><<a href="mailto:vances@motivity.ca">vances@motivity.ca</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;">
<div class="Ih2E3d">On Sun, Sep 07, 2008 at 10:02:37AM -0400, Luke Galea wrote:<br>
} I get the sense that most erlangers feel that regular expressions<br>
} aren't needed and that pattern matching can do the job.<br>
<br>
</div>Whenever possible.<br>
<br>
} ([m|l])ouse$ -> $1ice<br>
<br>
-module(inflector).<br>
-export([singularize/1]).<br>
<br>
singularize(Word) -><br>
L = lists:reverse(Word),<br>
lists:reverse(singularize1(L)).<br>
<br>
singularize1("ecil" ++ L) -><br>
"esuol" ++ L;<br>
singularize1("ecim" ++ L) -><br>
"esuom" ++ L.<br>
<br>
1> inflector:singularize("titmice").<br>
"titmouse"<br>
<br>
If you're really just dealing in words the penalty of a double<br>
reverse isn't as bad as the penalty of having to use REs.<br>
<font color="#888888"><br>
-Vance<br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
</div></div></blockquote></div><br></div>