title: Prolog: Matching elements in a specific between two lists
body: <p>I already have this code to match if any numbers in a list match any numbers in the other list. However, I need to modify my recursion so it returns false if the same number is found in the same position on both lists.</p>
  
  <p>For example:</p>
  
  <p><code>[5,3,4,6,2]</code> is compatible with <code>[3,1,2,2,7]</code>; and <code>[1,3,4,9,2]</code> is incompatible with <code>[4,5,2,9,8]</code> because both lists have a 9 in the 4th position.</p>
  
  <p>Here is the code I have so far:</p>
  
  <pre><code>common_elements([], L) :-
      fail.
  common_elements([H|T], L) :-
      memberchk(H, L), !.
  common_elements([H|T], L) :-
      common_elements(T, L).
  </code></pre>
  
  <p>SWI-Prolog example inputs and outputs for current code:</p>
  
  <pre><code>?- common_elements([1,2,3,4],[6,7,8,9]).
  false.
  
  ?- common_elements([1,2,3,6],[6,7,8,9]).
  true.
  </code></pre>