title: Prolog Operator Priority Clash on multiple Ifs
body: <p>I'm kind of new to prolog and can't figure out what's wrong with this.</p>
  
  <pre><code>ecoZona(Z):-
  zona(Z, L1),
  (L1 = [] -&gt; 
      write('Zona nao encontrada'), nl,nl ;
      write('cenas\n'),
      listaEcos(L1,A,B,C,D),
      format('Ha ~w de Lixo Organico\n ~w de Papel\n ~w de Metal\n ~w de Vidro', [A, B, C, D]),
      max([A, B, C, D], X),
      F is div(700,X),
      M is mod(700,X),
      ( M &lt;0 -&gt; F is F+1; F is F+0),
      format('Sao Precisos ~w camioes', [F])).
  
  
  listaEcos([],A,B,C,D).
  listaEcos([L|R],A,B,C,D):-
  findall([I,T,_,P], ecoponto(I, T, _, P), L2),
  (L2 = [] -&gt;
      write('---------\n');
      somaMais(L2,A,B,C,D)),
  listaEcos(R,A,B,C,D).
  
  somaMais([],A,B,C,D).
  somaMais([L3|R3],A,B,C,D):-
  nth0(1, L3, ElemType),
  nth0(3, L3, ElemPerc),
  ( ElemPerc &gt;= 90 -&gt;
      (ElemType = 'Organico'
          -&gt; soma(A,ElemPerc,F);
              (ElemType = 'Papel'
                  -&gt; soma(B,ElemPerc,G);
                      (ElemType = 'Metal'
                          -&gt; soma(C,ElemPerc,H);
                          soma(D,ElemPerc,I),
                      )
              )
      )
  somaMais(R3,F,G,H,I)).
  
  
  soma(A,Elem, H):-
  H is A+Elem.    
  </code></pre>
  
  <p>SWI-Prolog tells me that there is a <code>Syntax error: Operator priority clash</code> on the line that corresponds to <code>soma(D,ElemPerc,I),</code>, what am I missing? Is it something wrong on all those ifs?</p>
  
  <p>I have a set of garbage cans (which have a name, type, location, capacity).
  The idea is that given a zone (that has several locations) I could get the sum of all the capacities over 90 from the garbage cans in that area.</p>
  
  <p>So ecoZona would grab the zone and "send it" to listaEcos, this one would split the list of garbage cans (and their properties) into individual garbage cans. and then somaMais would sum the capacities (splitting paper, glass, metal and organic)</p>