# Sets of variables in terms

**Author(s):**The CLIP Group.

This module implements predicates to handle sets of variables in terms.

## Usage and interface

**Library usage:**`:- use_module(library(terms_vars)).`**Exports:***Predicates:*`varset/2`,`intersect_vars/3`,`member_var/2`,`diff_vars/3`,`varsbag/3`,`varset_in_args/2`,`term_variables/2`,`term_variables/3`.

**Imports:***System library modules:*`idlists`,`sort`.*Packages:*`prelude`,`nonpure`,`assertions`.

## Documentation on exports

PREDICATE

`varsbag(Term,Vs,Xs)`

Vs is the list of all the variables in Term ordered as they appear in Term right-to-left depth-first (including duplicates) plus Xs.

PREDICATE

**Usage:**`varset_in_args(T,LL)`

Each list of LL contains the variables of an argument of T, for each argument, and in left to right order.

*The following properties should hold at call time:*

(term_typing:nonvar/1)T is currently a term which is not a free variable.*The following properties should hold upon exit:*

(basic_props:list/2)LL is a list of list(var)s.

PREDICATE

**Usage:**ISO`term_variables(Term,Vars)`

Vars is the list of all the variables in Term, ordered as they appear in Term right-to-left depth-first (without duplicates).

PREDICATE

`term_variables(Term,Vars,Tail)`

Vars-Tail is the difference list of all the variables in Term, ordered as they appear in Term right-to-left depth-first (without duplicates).