[erlang-questions] Versioned variable names
Bryan Fink
bryan.fink@REDACTED
Tue Jun 9 19:15:46 CEST 2009
On Tue, Jun 9, 2009 at 11:12 AM, Attila Rajmund
Nohl<attila.r.nohl@REDACTED> wrote:
> ... it wasn't possible to easily nest the whole into one call, but
> that would be still ugly
I like Paul's suggestion of using lists:foldl/3, but I have to contest
the assertion that nesting this whole call is ugly. I don't see the
ugliness in:
sanitize(MO) ->
ensure_hyphen(
re:replace(
toupper(re:replace(MO, "_", "-", [{return, list}, global])),
"RX0", "RXO", [{return, list}, global])).
ensure_hyphen(MO) ->
case re:run(MO, "-", [{capture, none}]) of
nomatch -> insert_hyphen(MO);
match -> MO
end.
-Bryan
More information about the erlang-questions
mailing list