• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
    • DSS Queries
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

4.21 Analysing and Constructing Terms
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Analysing and Constructing Terms
          • functor/3
          • 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
          • copy_term/2
          • Non-logical operations on terms
    • Packages
Availability:built-in
[ISO]functor(?Term, ?Name, ?Arity)
True when Term is a term with functor Name/Arity. If Term is a variable it is unified with a new term whose arguments are all different variables (such a term is called a skeleton). If Term is atomic, Arity will be unified with the integer 0, and Name will be unified with Term. Raises instantiation_error() if Term is unbound and Name/Arity is insufficiently instantiated.

SWI-Prolog also supports terms with arity 0, as in a() (see section 5. Such terms must be processed using compound_name_arity/3. The predicate functor/3 and =../2 raise a domain_error when faced with these terms. Without this precaution, the inconsistency demonstrated below could happen silently.95Raising a domain error was suggested by Jeff Schultz.

?- functor(a(), N, A).
N = a, A = 0.
?- functor(T, a, 0).
T = a.
ClioPatria (version V3.1.1-21-gb8003bb)