if and fun with erl
Steve Strong
steve@REDACTED
Tue Feb 1 14:26:13 CET 2011
You were close, tried *almost* every combination :) Try this:
13> Compare = fun(X, Y) ->
if X>Y -> greater;
X==Y -> equal;
X<Y -> less
end
end.
You need an "end" to the "if" and an "end" to the "fun". The first end doesn't need a comma after it since it is the last statement in the fun.
--
Steve Strong
twitter.com/srstrong
On Tuesday, February 1, 2011 at 2:20 PM, Yann SECQ wrote:
> 13> Compare = fun(X, Y) ->
> if X>Y -> greater;
> X==Y -> equal;
> X<Y -> less
> end,
> end.
More information about the erlang-questions
mailing list