4.21 Analysing and Constructing Terms
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Analysing and Constructing Terms
          • functor/3
          • functor/4
          • arg/3
          • =../2
          • compound_name_arity/3
          • compound_name_arguments/3
          • numbervars/3
          • numbervars/4
          • var_number/2
          • term_variables/2
          • nonground/2
          • term_variables/3
          • term_singletons/2
          • is_most_general_term/1
          • copy_term/2
          • copy_term/4
          • copy_term_nat/4
          • Non-logical operations on terms
    • Packages
Availability:built-in
copy_term(+VarsIn, +In, -VarsOut, -Out)
Similar to copy_term/2, but only rename the variables in VarsIn that appear in In.116This predicate is based on a similar predicate in s(CASP) by Joaquin Arias. Variables in In that do not appear in VarsIn are shared between In and Out. Sub terms that only contain such shared variables are shared as a whole between In and Out. VarsIn is often a list, but can be an arbitrary term. For example:
?- copy_term([X], q(X,Y), Vars, Term).
Vars = [_A],
Term = q(_A, Y).

Note that if VarsIn and In do not share any variables, Out is equivalent to In and VarsOut is a copy (as copy_term/2) of VarsIn. If In does not contain any variables not in VarsIn the result is the same as copy_term(VarsIn-In, VarsOut-Out).