I got this very newb and simple function in erlang:
function_x(L) ->
X = lists:filter((fun(N)-> N =:= 2 end), L),
Y = lists:filter((fun(N)-> N =:= 3 end), L),
LX = length(X),
LY = length(Y),
LX == 2 or LY == 2.
Compile the source, and I get this error:
syntax error before: '=='
I pull of one of the expressions from the or clausule and it works. I’m very newb in erlang as you see and really don’t understand why this happens if it seems so simple. Any help? Thanks
According to the operator precedence in Erlang, the precedence of
oris higher than that of==. So your expression as written is treated aswhich is a syntax error. To fix this, you must use parentheses around each term:
Alternatively, you can use
orelsewhich has a lower precedence than==: