functor, `functor`
In Prolog, the word functor is used to refer to the atom at the start of a structure, along with its arity, that is, the number of arguments it takes. For example, in `likes(mary, pizza)`, `likes/2` is the functor. In a more complex structure, like

`persondata(name(smith, john), date(28, feb, 1963))`

the top-level functor is termed the principal functor - in this case `persondata/2` - There is also a built-in predicate called `functor`, used to extract the name part and arity of a structure.

This built-in predicate takes three arguments: `functor(Term, Name, Arity)`. It succeeds if `Term` is a term with functor name `Name` and arity `Arity`. Examples:

```?- functor(likes(mary, pizza), Name, Arity).
Name = likes
Arity = 2

?- functor(likes(X, Y), Name, Arity).
X = _G180
Y = _G181
Name = likes
Arity = 2

?- functor(likes, Name, Arity).
Name = likes
Arity = 0

?- functor(X, likes, 2).
X = likes(_G232, _G233)
```

Sometimes there are reasons to want to have the functor name somewhere other than at the start of the structure. For example, in the expression `X < Y`, "`<`/2" is the functor, and so "`<`" is the functor name:

```?- functor(2 < 4, Name, Arity).
Name = (<),
Arity = 2.

?- 2 < 4.
true.

?- <(2, 4).
true.
```
See op to find out how this works.

The term functor is used in a different sense in mathematics and in functional programming, and a different way again in philosophy.