exported variables (was: RE: How to make GS Widgets)
Ulf Wiger
ulf.wiger@REDACTED
Fri Apr 16 20:19:42 CEST 2004
On Fri, 16 Apr 2004 08:55:47 -0700, Jay Nelson <jay@REDACTED> wrote:
> I tend more towards Joe's inefficient clarity style. Make a support
> function so that you don't have this kind of complicated indentation:
Agreed, but...
> validate_colors({R, _, _}) when not is_integer(R); R < 0; R > 255 ->
> {0,0,0};
> validate_colors({_, G, _}) when not is_integer(G); G < 0; G > 255 ->
> {0,0,0};
> validate_colors({_, _, B}) when not is_integer(B); B < 0; B > 255 ->
> {0,0,0};
> validate_colors({R, G, B}) ->
> {R, G, B};
> validate_colors(_) ->
> {0,0,0}.
... is how how I would write it. (:
validate_colors({R, G, B}) ->
VC = fun(C) -> validate_color(C) end,
{VC(R), VC(G), VC(B)}.
validate_color(C) when is_integer(C), C > 0, C < 255 ->
C.
/Uffe
--
Ulf Wiger
More information about the erlang-questions
mailing list