library(backcomp). The variables in List are ordered in order of appearance traversing Term depth-first and left-to-right. See also term_variables/3. For example:
?- term_variables(a(X, b(Y, X), Z), L). L = [X, Y, Z].
Tag confusing pages with doc-needs-help|Tags are associated to your profile if you are logged in