So I have this code to remove any element=X from a list.
remove(X,[],L).
remove(X,[X|T],Result):- remove(X,T,Result), !.
remove(X,[H|T],[H|Result]):- remove(X,T,Result).
But when I run it, in the result I get this weird |_G19
.
I understand this has to do with the [Head|Tail]
thingy
but I can't figure out a way to get rid of it from my result.
?- remove(2,[1,2,3,2,5,6,2],R).
R = [1, 3, 5, 6|_G19].
So what's wrong with it?
Why does this 6|_G19
appears?
How do I get rid of it?
Everything else is working as intended.