[erlang-questions] illegal guard expression with lists:nth

Bengt Kleberg <>
Thu Jun 11 11:48:35 CEST 2009


Greetings,

Not all functions are allowed in a guard. I can not think of any
function outside of the ones in the erlang module (like erlang:length/1)
that are allowed.


bengt

On Thu, 2009-06-11 at 11:37 +0200, Roberto Ostinelli wrote:
> dear all,
> 
> why does the following expression give me an 'illegal guard  
> expression' at compile?
> 
> if
> 	lists:nth(2, List) =:= "test" ->
> [...]
> 
> lists:nth returns a term, thus i should be enabled to use it. on the  
> contrary, the following expression is accepted:
> 
> if
> 	length(List) =:= 3 ->
> [...]
> 
> am i missing a point?
> 
> r.
> 
> 
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
> 



More information about the erlang-questions mailing list