title: Prolog - Binary addition?
body: <p>I need to write a Prolog predicate which calculate the sum of 2 binary numbers represented in list.
  The lists are already reversed, for example ([0,1] base 2) = (2 base 10).</p>
  
  <p>It should work with mode binary_plus(+,+,-), for example</p>
  
  <pre><code>?- binary_plus([1,1],[1],X).
  X = [0,0,1].
  </code></pre>
  
  <p>and with mode binary_plus(-,-,+), for example</p>
  
  <pre><code>?- binary_plus(X,X,[0,1]).
  X = [1].
  </code></pre>
  
  <p>Im <strong>not allowed</strong> using cut sign,findall,negation,or if-then-else.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>is_binary([]).
  is_binary([X]):- X is 1.
  is_binary([X|Xs]):-
      append(_,[1],Xs),
      member(X,[0,1]),    
      is_binary(Xs).
  
  binary_plus([],X,X):-
      is_binary(X).
  binary_plus(X,[],X):- 
      is_binary(X).
  
  binary_plus([0|Xs],[Y|Ys],[Y|Zs]):-
      binary_plus(Xs,Ys,Zs).
  binary_plus([1|Xs],[0|Ys],[1|Zs]):-
      binary_plus(Xs,Ys,Zs).
  binary_plus([1|Xs],[1|Ys],[0|Zs]):-
      binary_plus(Xs,[1],Ws),
      binary_plus(Ws,Ys,Zs).
  </code></pre>
  
  <p>I dont know where i'm wrong because there are some strange issues that i cant solve,
  so if someone could help me i would appreciate it.
  Thanks.</p>