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?
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).
When consulting with ?- separate([3,a,b,4,5,c],X,Y).
I get:
X = [3, 4, 5|_G2592],
Y = [a, b, c] .