functor/3

Conversion between a term and its functor and arity

functor(Term,Functor,Arity) -(?,?,?)

Succeed if the Func is the functor of a Term with the given Arity

Example

functor(D,date,3),

arg(1,D,17),

arg(2,D,april),

arg(3,D,1997).

D=date(17,april,1997)

1 Solution

?Term <term> or <variable>

?Functor <term> or <variable>

?Arity <integer> or <variable>

Remarks: This predicate succeeds if the given Term has the specified Functor and Arity. If Term is an uninstantiated variable, then Arity must be an integer greater than or equal to zero (0): if Arity is zero, Term will be bound to Functor; otherwise, it will be bound to a compound term with the given Functor and Arity, each argument being defined as a distinct unbound variable.