title: How can plus a list of lists in prolog?
body: <p>I need a predicate which plus of a list of lists in prolog using pure logic and natural number notation.
  For example for the predicate :</p>
  
  <p><code>?-totalPlus([ [s(0)],[s(0),s(0)],[s(s(0))] ], Res).</code></p>
  
  <p>The result must be:</p>
  
  <pre><code>Res= s(s(s(s(s(0))))).
  </code></pre>
  
  <p>This is my implementation but it only returns the plus of the first list:</p>
  
  <pre><code>    plusNat(0,X,X).
      plusNat(s(X),Y,s(Z)):-plusNat(X,Y,Z).
  
      plusList([],0).
      plusList([X|Xs], S) :- plusList(Xs,SXs), plusNat(X,SXs,S).
  
      totalPlus([],_).
      totalPlus([X|Xs],Y):-totalPlus(Xs,_), plusList(X,Y).
      ------------------
  
      ?-totalPlus([ [s(0)],[s(0),s(0)],[s(s(0))] ], Res).
        Res= s(0).
  </code></pre>
  
  <p>Thanks in advance!</p>