[erlang-questions] illegal guard expression with lists:nth
Thu Jun 11 11:50:58 CEST 2009
On Thu, Jun 11, 2009 at 11:37 AM, Roberto Ostinelli<> wrote:
> dear all,
> why does the following expression give me an 'illegal guard expression' at
> 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:
> length(List) =:= 3 ->
> am i missing a point?
You cannot use any function you want in a guard, but only a few BIFs.
length/1 is one of them, lists:nth/2 is not.
Check the manual for "guard sequences".
More information about the erlang-questions