title: prolog two lists are exactly the same
body: <p>I want to write a function that returns true if two lists are exactly the same(order of elements matters).</p>
  
  <p>I tried it this way:</p>
  
  <pre><code>same([ ], [ ]).   
  same([H1|R1], [H2|R2]):-
      H1 == H2,
      same(R1, R2).
  </code></pre>
  
  <p>It returns true while two lists are the same, also I expect if I have </p>
  
  <pre><code>?- same(X, [1, 2, 3]).
  </code></pre>
  
  <p>I want it to return</p>
  
  <pre><code>X = [1, 2, 3].
  </code></pre>
  
  <p>But it doesn't work if input is like this. Here are some sample outputs I got:</p>
  
  <pre><code>?- same([1, 2], [1, 2]).
  
  true.
  
  ?- same([2, 1], [1, 2]).
  
  false.
  
  ?- same(X, [1, 2, 3]).
  
  false.
  
  ?- same([1, 2, 3], [1, 2, X]).
  
  false.
  </code></pre>
  
  <p>How to fix it?</p>