[erlang-questions] String Pattern Matching
Sun Sep 7 21:31:46 CEST 2008
>If you're really just dealing in words the penalty of a double
>reverse isn't as bad as the penalty of having to use REs.
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 ;-)
On Sun, Sep 7, 2008 at 2:47 PM, Vance Shipley <> wrote:
> On Sun, Sep 07, 2008 at 10:02:37AM -0400, Luke Galea wrote:
> } I get the sense that most erlangers feel that regular expressions
> } aren't needed and that pattern matching can do the job.
> Whenever possible.
> } ([m|l])ouse$ -> $1ice
> singularize(Word) ->
> L = lists:reverse(Word),
> singularize1("ecil" ++ L) ->
> "esuol" ++ L;
> singularize1("ecim" ++ L) ->
> "esuom" ++ L.
> 1> inflector:singularize("titmice").
> If you're really just dealing in words the penalty of a double
> reverse isn't as bad as the penalty of having to use REs.
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions