<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Yes, this looks much better. I just wanted to figure out how guards
are evaluated.<br>
<br>
<div class="moz-cite-prefix">On 1/5/2015 11:04 AM, Danil Zagoskin
wrote:<br>
</div>
<blockquote
cite="mid:CAJ6dJEiERRjgmrXtLA1fmksxUkpnGn=W0_uwhFg5gjeQ6Jp6Wg@mail.gmail.com"
type="cite">
<div dir="ltr">Alternatively, you may split complex logic to
several clauses:
<div>f(N, M) when N > 100, M > 100 -> % Both too large</div>
<div> not_cool;</div>
<div>f(N, M) when N < 100, M < 100 -> % Both too small</div>
<div> not_cool;</div>
<div>f(N, M) when N > 0, M > 0 -> % Both are greater
than 0, after previous clauses exactly one of them greater
than 100</div>
<div> cool;</div>
<div>f(_, _) -></div>
<div> not_cool.</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Jan 5, 2015 at 11:51 AM, Martin
Koroudjiev <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:mrtndimitrov@gmail.com" target="_blank">mrtndimitrov@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
First of all - Happy New Year!<br>
<br>
Suppose we have a function that accepts 2 integers and we
want to react<br>
only when both integers are greater than 0 and one of them
is less than 100:<br>
<br>
I tried:<br>
(dilbert@Martin-PC)1> F = fun(N, M) when N > 0, M >
0, N < 100; M < 100<br>
-> cool; (_, _) -> not_cool end.<br>
#Fun<erl_eval.12.106461118><br>
(dilbert@Martin-PC)2> F(1,2).<br>
cool<br>
(dilbert@Martin-PC)3> F(1,200).<br>
cool<br>
(dilbert@Martin-PC)4> F(0,200).<br>
not_cool<br>
(dilbert@Martin-PC)5> F(0,50).<br>
cool<br>
<br>
The last is not correct.<br>
What is the order of evaluation of the guards? Sadly
parentheses are not<br>
allowed in guards.<br>
<br>
Best regards,<br>
Martin<br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a moz-do-not-send="true"
href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a moz-do-not-send="true"
href="http://erlang.org/mailman/listinfo/erlang-questions"
target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="gmail_signature">
<div dir="ltr">
<div><font face="'courier new', monospace">Danil Zagoskin |
<a moz-do-not-send="true" href="mailto:z@gosk.in"
target="_blank">z@gosk.in</a></font></div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>