You can't store predicates in a list, but you can store terms (or functors) and call terms as goals.
Here's a predicate that tests whether a term has the properties described by a list of functors:
has_properties([], _).
has_properties([P|Ps], X) :-
Goal =.. [P, X], % construct goal P(X)
call(Goal),
has_properties(Ps, X).
Usage:
% is 4 a number, an integer and a foo?
?- has_properties([number, integer, foo], 4).
The answer to this query will depend on your definition of foo/1
, of course. See my explanation of =..
if needed.
Edit: as @false reports in the comments, it's not necessary to use =..
, since Goal =.. [P, X], call(Goal)
can be replaced by call(P, X)
will have the same effect. It might still be worthwhile learning about =..
, though, as you may encounter it in other people's code.