Availability:built-in
[ISO]term_variables(+Term,
-List)Unify List with a list of variables, each sharing with a
unique variable of Term.116This
predicate used to be called free_variables/2 . The name term_variables/2
is more widely used. The old predicate is still available from the
library 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
and nonground/2.
For example:
?- term_variables(a(X, b(Y, X), Z), L).
L = [X, Y, Z].