sitelogo
functor/3

creates a compound term or determines functor and arity.

functor(+CompoundTerm, -Functor, -Arity)
functor(-CompoundTerm, +Functor, +Arity)

If CompoundTerm is a compound term then Functor is the functor and Arity is the arity of that CompoundTerm.
If CompoundTerm is an atomic term (an atom or a number) then Functor is that atomic term and Arity is 0.
If CompoundTerm is a variable then Functor must be an atomic term and Arity must be an integer between 0 and max_arity (127). If is not an atom, the arity must be 0.

Arguments

CompoundTerm           compound term or atomic term
Functor                atomic term
Arity                  integer or integer-expression (between 0 and 127)

Examples

functor(f(a,b,c),F,A). Succeeds with substitution F <- f, A <- 3.
functor(X,functor,3). Succeeds with substitution X <- functor(_1, _2, _3).
functor(f(X),f,2). Fails.

Standard

This predicate is part of the ISO-Prolog Standard.

See also

arg/3, copy_term/2, '=..'/2.


Darueber read on...
scroll to top managed with ubiCMS