?- functor(fact(male(fred),23),F,N).The predicate functor/3 can be used to find the principal functor of a compound term together with its arity. It can also be used to generate structures:F=fact
N = 2
?- functor(X,example,2).except that the variables will be shown differently.X = example(A,B)