[ Term Manipulation | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]
copy_term(+OldTerm, ?NewTerm, ?MetaTerms)
A copy of OldTerm with new variables is created and unified with NewTerm.
MetaTerms is a list mapping the metaterms in OldTerm to the corresponding
variables in NewTerm.
- +OldTerm
- Prolog term.
- ?NewTerm
- Prolog term, normally a variable.
- ?MetaTerms
- 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 metaterms. Instead it copies the
metaterms as normal variables, and returns the MetaTerms list as
a means to define the copying of metaterms separately. MetaTerms is a
list of pairs [<metaterm>|<variable>] which maps the metaterms 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 metaterm.
Note that copy_term/2 is implemented as
copy_term(X, Y) :-
copy_term(X, Y, Metas),
apply_copy_term_handlers(Metas).
Fail Conditions
Fails if NewTerm does not unify with the copy of OldTerm.
Resatisfiable
No.
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