Search code examples
prolog

How to construct a Predicate Indicator?


I want to use the ISO current_predicate/1 predicate, but with a constructed argument (the "predicate indicator").

So rather than querying the predicate indicator literally, like current_predicate(foo/1), I want to do something like

check_pred(P):-
   ???(P,1,P1),
   current_predicate(P1). % P1 must be a predicate indicator
check_pred(foo).

For the ???, neither functor(P1, P, 1) works (as it constructs a term), nor atom_concat(P, '/1', P1) (as it constructs an atom).

How can I do that?


Solution

  • Promoting @false comment to an answer:

    Use (/)/2, That is P1 = P/1