title: Uninstantiated variable at end of list in SWI-Prolog
body: <p>I wrote a program to sort numbers from symbols, and it works, but gives me a memory address at the end of the list that it didn't run through last. Why is that so?</p>
  
  <pre><code>separate([],[],[]).
  separate([X],X,_):-number(X).
  separate([X],_,X).
  separate([X|Y],[X|Z],S):-number(X),separate(Y,Z,S).
  separate([X|Y],Z,[X|S]):-separate(Y,Z,S).
  </code></pre>
  
  <p>When consulting with <code>?- separate([3,a,b,4,5,c],X,Y).</code></p>
  
  <p>I get:</p>
  
  <pre><code>X = [3, 4, 5|_G2592],
  Y = [a, b, c] .
  </code></pre>