I'm using the swi-prolog build in predicate to get a list of variables from a term. I am then trying to print them out with their sequence number. Unfortunately I'm only able to print their internal _2902 names instead of X,Y, etc. Is there a way to preserve the names? preferably not implementation dependant. Here is what I have:
assign_numbers(Term) :-
term_variables(Term, L),
print_values(L,0).
% take a list of variables and print them out with their index according to their appearance order.
print_values([],_).
print_values([X|Xs],C) :-
C1 is C + 1,
write(X),tab(1),write(=),tab(1),write(C1),nl,
print_values(Xs,C1).
As a side question I would also like to see the implementation of the build in predicate term_variables from swi-prolog but I cant find it.