
term_variables_array(?Term, -VarArr)

   Succeeds if VarArr is an array containing all variables in Term.

Arguments
   Term                Prolog term.
   VarArr              Array or variable.

Type
   Term Manipulation

Description

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

   As usual, attributed variables are also considered variables.

   This predicate terminates even with cyclic terms.



Modes and Determinism
   term_variables_array(?, -) is det

Examples
   
Success:
    term_variables_array(atom, []).
    term_variables_array(Term, Vz).       % gives Vz = [](Term)
    term_variables_array(f(a,B,c), Vz).   % gives Vz = [](B)
    term_variables_array([X,Y,Z], Vz).    % gives Vz = [](X,Y,Z)
    term_variables_array([X,Y,X], Vz).    % gives Vz = [](X,Y)
    term_variables_array(s(X{a}), Vz).    % gives Vz = [](X{a})

Fail:
    term_variables_array(f(a,B,c), []).


See Also
   term_variables / 2, nonvar / 1, var / 1
