IF Computer > MINERVA > Manual > Reference > Predicates > Term creation and decomposition > functor/3

functor/3

MINERVA
ifcomputer logo
f
Expert Services on the Web

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.

document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Predicates/term_creat_decomp/functor/print_en.html
published 2008/9/1 update 1998/8/7 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 start (AT) ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
Back> managed with ubiCMS