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
functor(?Term, ?Name, ?Arity, ?Type)
As functor/3, but designed to work with zero-arity terms (e.g., a(), see section 5). Type is one of atom, compound, callable or atomic. Type must be instantiated if Name is an atom and Arity is 0 (zero). In other cases Type may be a variable. This predicate is true if Term (either initially or after haveing been created from Name and Type) and Type are related as below

  • If Term is compound (including zero-arity compounds), Type must be compound or callable. If Type is unbound is is unified with compound.
  • If Term is an atom, Type must be atom or callable. If Type is unbound is is unified with atom.
  • Else Type is unified with atomic.

This predicate provides a safe round trip for zero-arity compounds and atoms. It can also be used as a variant of functor/3 that only processes compound or callable terms. See also compound/1, callable/1 and compound_name_arity/3.