
term_variables(?Term, -VarList)

   Succeeds if VarList is the list of all variables in Term.

Arguments
   Term                Prolog term.
   VarList             List or variable.

Type
   Term Manipulation

Description

   This predicate collects all the variables inside Term into the list
   VarList.  Every variable occurs only once in VarList, even if it occurs
   several times in Term.  The order of the variables in the list
   corresponds to the order in which they are first encountered during
   a depth-first, left-to-right traversal of Term.

   As usual, attributed variables are also considered variables.

   This predicate can handle cyclic terms.

   Compatibility Note: In ECLiPSe releases prior to 7.0, the list was
   constructed in reverse order. Use eclipse_6:term_variables/2 if you
   require this behaviour.  The new behaviour is compatible with ISO-Prolog.



Modes and Determinism
   term_variables(?, -) is det

Exceptions
     5 --- VarList instantiated but not to a list.

Examples
   
    term_variables(atom, Vs).	      % gives Vs = []
    term_variables(Term, Vs).         % gives Vs = [Term]
    term_variables(f(a,Y,c), Vs).     % gives Vs = [Y]
    term_variables(f(X,g(Y),c), Vs).  % gives Vs = [X,Y]
    term_variables(X+3*Y, Vs).        % gives Vs = [X,Y]
    term_variables([X,Y,Z], Vs).      % gives Vs = [X,Y,Z]
    term_variables([X,Y,X], Vs).      % gives Vs = [X,Y]
    term_variables(s(X{a}), Vs).      % gives Vs = [X{a}]


See Also
   eclipse_6 : term_variables / 2, term_variables_array / 2, term_variables_count / 2, nonground / 1, nonground / 2, nonground / 3, nonvar / 1, var / 1
