[erlang-questions] Guards?

Roger Lipscombe roger@REDACTED
Tue Apr 5 14:56:59 CEST 2016


That gets parsed as:

F = fun(X) when ((is_integer(X) or is_float(X)) and X) < 5 -> ok end.

You can check by looking at the output of erlang:fun_info(F), which
shows the parse tree for the guard condition.

On 5 April 2016 at 13:27, Roberto Ostinelli <roberto@REDACTED> wrote:
> All,
> I'm a little stumped and I feel I'm missing something sooooooo beginner
> here.
>
> 1> F = fun(X) when (is_integer(X) or is_float(X)) and X < 5 -> ok end.
> #Fun<erl_eval.6.50752066>
> 2> F(1).
> ** exception error: no function clause matching
> erl_eval:'-inside-an-interpreted-fun-'(1)
> 3> F2 = fun(X) when (is_integer(X) or is_float(X)) and (X < 5) -> ok end.
> #Fun<erl_eval.6.50752066>
> 4> F2(1).
> ok
>
> ...Can some kind soul clarify?
>
> Thank you,
> r.
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list