Next: , Previous: , Up: mpg-bpr   [Contents][Index]


11.3.235 term_variables/2   ISO

Synopsis

term_variables(+Term, -Variables)   since release 4.3 True if Variables is the list of variables occurring in Term, without duplicates, in first occurrence order.

Arguments

Term

Any term, a cyclic term is also accepted.

-Variables

The variables in the term. Must be a variable or a list.

Exceptions

type_error

Variables is not a variable or a list.

Description

Please note: “first occurrence order” is not, in general, well-defined for cyclic terms. This means that for two equal cyclic terms the order of the list of variables returned by term_variables/2 may differ. Sorting, e.g. with sort/2, can be used to obtain the ordered set of variables of a term. The set of variables in a term will be the same for any pair of equal terms, including cyclic terms.

Examples

| ?- term_variables(f(A, B, A), Vs).
Vs = [A,B] ?
yes
| ?- term_variables(f(a, b, a), Vs).
Vs = [] ?
yes
| ?- T=[A,B|T], term_variables(f(C,T), Vs).
T = [A,B,A,B,A,B,A,B,A,B|...],
Vs = [C,A,B] ? 
yes

See Also

ref-lte-act.


Send feedback on this subject.