I need to implement the predicate
term_variables
I need to get a term and return a list of variables (every variable only once).
for every new variable i check if its a member of a list if not then add the variable name to the list.
my problem is that when i save the variable in the list it gets saved a _g474 and i need to save it as the variable name X.
Is there any way to get the variables name?
Thanks
My Code:
term_variables(Term) :-
Term=..L,
term_variables(L, []).
term_variables([X| Xs], Vars):-
compound(X),
X=..L,
term_variables(L, Vars)
;
var(X),
not(member(X, Vars)),
write(X),
term_variables(Xs, [X|Vars])
;
term_variables(Xs, Vars).
term_variables([], _,).