<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Cool. Thanks. This works as expected:<br>
<br>
G = fun(N, M) when (N > 0 andalso M > 0) andalso (N < 100
orelse M < 100) -> cool; (_, _) -> not_cool end.<br>
<br>
<div class="moz-cite-prefix">On 1/5/2015 10:53 AM, Sergej Jurečko
wrote:<br>
</div>
<blockquote
cite="mid:CAAbM2=YwhPgm6So7mN6s9Fk3-1v4K-S8SUa5OmZT-R5FBx6V=A@mail.gmail.com"
type="cite">
<p dir="ltr">You can use paranthesis with andalso and orelse <br>
</p>
<p dir="ltr">Sergej</p>
<div class="gmail_quote">On Jan 5, 2015 9:51 AM, "Martin
Koroudjiev" <<a moz-do-not-send="true"
href="mailto:mrtndimitrov@gmail.com">mrtndimitrov@gmail.com</a>>
wrote:<br type="attribution">
<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.<a moz-do-not-send="true"
href="tel:12.106461118" value="+12106461118">12.106461118</a>><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>
</blockquote>
<br>
</body>
</html>