Thank you for the answer; there’s big difference between the use of ‘term_string/3’ and ‘term_to_atom/2’ in terms of “results”? I want to obtain an atom(or string) from a var in a term; i think (but i’m new in Prolog) that the type of output i need (atom or string) not change, so it’s the same if i use ‘term_string/3’ or ‘term_to_atom/2’; this not affect the analysis of order, right? On SWI-Prolog version 8.1.22 i don’t have such problems, the query in my post give different result on SWISH.
I dont know definition of the result Y of term_to_atom(X, Y) when X is unboud. So, such difference is not so strange for me, but I believe some readers are able to answer precisely to your question.
The real problem is that Prolog variables do not have names So, term_to_atom(A, X) produces something like X = _2422 or some other weird number. When you do the comparison of these two mostly meaningless numbers you get a meaningless result.
One of the few things that give variables names in normal Prolog is read_term/3 with the option variable_names(Names).
In fact, you can also get access to the query variable names in SWISH using
?- b_getval('$variable_names', Names).
Still, as a beginner it is better to get used to Prolog variables as things without a name.