[ Term Manipulation | Reference Manual | Alphabetic Index ]

copy_term(?OldTerm, -NewTerm, -AttrVars)

A copy of OldTerm with new variables is created and unified with NewTerm. AttrVars is a list mapping the attributed variables in OldTerm to the corresponding variables in NewTerm.
OldTerm
Prolog term.
NewTerm
Prolog term, normally a variable.
AttrVars
List of Pairs or a variable.

Description

A copy of OldTerm is created, ie. a term that is similar to OldTerm but the free variables of OldTerm have been replaced by new variables which do not occur elsewhere. In other words, the new term is a most general variant of the old one in the sense of variant/2.

This predicate is a more primitive version of copy_term/2 and does not imply a particular handling of attributed variables. Instead it copies the attributed variables as normal variables, and returns the AttrVars list as a means to define the copying of attributed variables separately. AttrVars is a list of pairs [<attributed variable>|<variable>] which maps the attributed variables in OldTerm to the corresponding fresh variables in NewTerm. By processing this list, the variables can be instantiated to whatever the user defines as the copy of the attributed variable.

Note that copy_term/2 is implemented as

    copy_term(X, Y) :-
        copy_term(X, Y, Metas),
        apply_copy_term_handlers(Metas).

Modes and Determinism

Examples

[eclipse 1]: set_flag(output_mode, "QPMV").

yes.
[eclipse 3]: copy_term(s(a,X{a},Y, Z{b}), Copy, Metas).

X = X_m234{a}
Y = Y_g224
Z = Z_m212{b}
Copy = s(a, _g282, Y_g288, _g292)
Metas = [[Z_m212{b}|_g292], [X_m234{a}|_g282]]
yes.



See Also

copy_term / 2, copy_term_vars / 3, variant / 2, term_variables / 2