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
[ISO]?Term =.. ?List
List is a list whose head is the functor of Term and the remaining arguments are the arguments of the term. Either side of the predicate may be a variable, but not both. This predicate is called‘Univ'.
?- foo(hello, X) =.. List.
List = [foo, hello, X]

?- Term =.. [baz, foo(1)].
Term = baz(foo(1))

SWI-Prolog also supports terms with arity 0, as in a() (see section 5). Such terms must be processed using compound_name_arguments/3. This predicate raises a domain error as shown below. See also functor/3.

?- a() =.. L.
ERROR: Domain error: `compound_non_zero_arity' expected, found `a()'