[erlang-questions] Order of evaluation of guards
Mon Jan 5 10:08:27 CET 2015
Yes, this looks much better. I just wanted to figure out how guards are
On 1/5/2015 11:04 AM, Danil Zagoskin wrote:
> Alternatively, you may split complex logic to several clauses:
> f(N, M) when N > 100, M > 100 -> % Both too large
> f(N, M) when N < 100, M < 100 -> % Both too small
> f(N, M) when N > 0, M > 0 -> % Both are greater than 0, after previous
> clauses exactly one of them greater than 100
> f(_, _) ->
> On Mon, Jan 5, 2015 at 11:51 AM, Martin Koroudjiev
> <mrtndimitrov@REDACTED <mailto:mrtndimitrov@REDACTED>> wrote:
> First of all - Happy New Year!
> Suppose we have a function that accepts 2 integers and we want to
> only when both integers are greater than 0 and one of them is less
> than 100:
> I tried:
> (dilbert@REDACTED)1> F = fun(N, M) when N > 0, M > 0, N < 100; M
> < 100
> -> cool; (_, _) -> not_cool end.
> (dilbert@REDACTED)2> F(1,2).
> (dilbert@REDACTED)3> F(1,200).
> (dilbert@REDACTED)4> F(0,200).
> (dilbert@REDACTED)5> F(0,50).
> The last is not correct.
> What is the order of evaluation of the guards? Sadly parentheses
> are not
> allowed in guards.
> Best regards,
> erlang-questions mailing list
> erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
> Danil Zagoskin | z@REDACTED <mailto:z@REDACTED>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions