7.1.3 Operations on terms with attributed variables
- copy_term(+Term, -Copy, -Gs)
- Create a regular term Copy as a copy of Term
(without any attributes), and a list Gs of goals that
represents the attributes. The goal
maplist(call, Gs)
recreates the attributes for Copy. The nonterminal attribute_goals//1, as defined in the modules the attributes stem from, is used to convert attributes to lists of goals.This building block is used by the top level to report pending attributes in a portable and understandable fashion. This predicate is the preferred way to reason about and communicate terms with constraints.
The form
copy_term(Term, Term, Gs)
can be used to reason about the constraints in whichTerm
is involved. - copy_term_nat(+Term, -Copy)
- As copy_term/2. Attributes, however, are not copied but replaced by fresh variables.
- term_attvars(+Term, -AttVars)
- AttVars is a list of all attributed variables in Term
and its attributes. That is, term_attvars/2
works recursively through attributes. This predicate is cycle-safe. The
goal
term_attvars(Term,[])
in an efficient test that Term has no attributes; scanning the term is aborted after the first attributed variable is found.