[ Term Manipulation | Reference Manual | Alphabetic Index ]

copy_term_vars(?Vars, ?OldTerm, -NewTerm)

NewTerm gets unified with a variant of OldTerm where all occurrences of variables in Vars are replaced by fresh variables.
Vars
Prolog term, usually a variable or a list of variables.
OldTerm
Prolog term.
NewTerm
Prolog term.

Description

A copy of OldTerm is created, ie. a term that is similar to OldTerm but all occurrences of the variables mentioned in Vars have been replaced by new variables which do not occur elsewhere.

Metaterms are treated like normal variables. Their attributes are copied as specified by the corresponding copy_term handler.

Subterms that do not contain any of the variables to replace are not physically copied.

Note that when the structure of the term to be copied is known, then it is more efficient to use specialised unification code to do the job.

Modes and Determinism

Examples

   [eclipse]: Term=s(X,Y,Z), copy_term_vars(Y, Term, Copy).
   X = _79
   Z = _81
   Y = _60
   Term = s(_79, _60, _81)
   Copy = s(_79, _120, _81)
   yes.



See Also

copy_term / 2, copy_term / 3, variant / 2, functor / 3, term_variables / 2