Reputation: 11
Check if the predicate functor(Term, F, A) succeeds if Term has functor F and arity A by defining a functor
The code I've tried is
likes(Mary,pizza)
Is this correct?
Upvotes: 1
Views: 252
Reputation: 4438
As described at https://www.swi-prolog.org/pldoc/man?predicate=functor/3
?- functor(likes('Mary', pizza), Name, Arity).
Name = likes,
Arity = 2.
?- functor(Term, likes, 2).
Term = likes(_,_).
Beware: Variables start with a capital letter, so the value Mary is 'Mary'
, because Mary is instead a reference to a variable.
Upvotes: 1