<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">What you're missing is operator precedence [1] - "and" takes precedence over "<", so your guard clause ends up looking, to the runtime, like what Bengt pointed out - you have the boolean expression `is_inteteger(X) or is_float(X)` followed by and, followed by X - which is evaluated before the < operator. The evaluation of your guard looks something like this:<div class=""><br class=""></div><div class="">X = 1</div><div class="">(((is_integer(1) or is_float(1)) and 1) < 5</div><div class=""><br class=""></div><div class="">(((true) and 1) < 5)</div><div class=""><br class=""></div><div class="">`true and 1` cannot be evaluated (throws an exception, as `and` doesn't take integer arguments). Now, your guard expression threw an exception - what happens then:</div><div class=""><br class=""></div><div class="">"If an arithmetic expression, a Boolean expression, a short-circuit expression, or a call to a guard BIF fails (because of invalid arguments), the entire guard fails. If the guard was part of a guard sequence, the next guard in the sequence (that is, the guard following the next semicolon) is evaluated." [2]</div><div class=""><br class=""></div><div class="">So, your guard ends up not matching - you have no other function clauses, so you have "no function clause matching."</div><div class=""><br class=""></div><div class="">Make sense now?</div><div class=""><br class=""></div><div class="">Doug</div><div class=""><br class=""></div><div class="">[1] <a href="http://erlang.org/doc/reference_manual/expressions.html#id84275" class="">http://erlang.org/doc/reference_manual/expressions.html#id84275</a></div><div class="">[2] <span style="color: rgb(71, 135, 255); text-decoration: underline;" class=""><a href="http://erlang.org/doc/reference_manual/expressions.html#id83710" class="">http://erlang.org/doc/reference_manual/expressions.html#id83710</a></span></div><div class=""><br class=""><div class=""><div><blockquote type="cite" class=""><div class="">On Apr 5, 2016, at 8:38 AM, Kostis Sagonas <<a href="mailto:kostis@cs.ntua.gr" class="">kostis@cs.ntua.gr</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On 04/05/2016 02:27 PM, Roberto Ostinelli wrote:<br class=""><blockquote type="cite" class="">I'm a little stumped and I feel I'm missing something sooooooo beginner<br class="">here.<br class=""><br class="">1> F = fun(X) when (is_integer(X) or is_float(X)) and X < 5 -> ok end.<br class="">#Fun<erl_eval.6.50752066><br class="">2> F(1).<br class="">** exception error: no function clause matching<br class="">erl_eval:'-inside-an-interpreted-fun-'(1)<br class="">3> F2 = fun(X) when (is_integer(X) or is_float(X)) and (X < 5) -> ok end.<br class="">#Fun<erl_eval.6.50752066><br class="">4> F2(1).<br class="">ok<br class=""><br class="">...Can some kind soul clarify?<br class=""></blockquote><br class="">It's a long story.  Its short version is that you will have a much better state of mind if you forget the presence of 'or' and 'and' in guards and use ';' and ',' when you can, and 'orelse' and 'andalso' when you cannot (as in your F fun).<br class=""><br class="">1> F = fun(X) when (is_integer(X) orelse is_float(X)) andalso X < 5 -> ok enD.<br class="">#Fun<erl_eval.6.50752066><br class="">2> F(1).<br class="">ok<br class=""><br class=""><br class="">Kostis<br class="">_______________________________________________<br class="">erlang-questions mailing list<br class=""><a href="mailto:erlang-questions@erlang.org" class="">erlang-questions@erlang.org</a><br class="">http://erlang.org/mailman/listinfo/erlang-questions<br class=""></div></div></blockquote></div><br class=""></div></div></body></html>