current_predicate(?predicate_indicator_pattern) [ISO]

Find the predicate indicators of the user-defined procedures (static or dynamic) in the active module of the database This predicate is re-executable as many times as there are clauses of which the predicate indicator matches with the specified indicator pattern.

see also: clause/2 number_vars/3 freeze/2 melt/3

Suppose the active module of the database contains the following predicates:

public.

elk(X) :- moose(X).

reverse([]) :- true.
reverse([], []) :- true.
reverse([E|L], R) :- reverse(L, Q), append(Q, [E], R).

legs(A, 6) :- insect(A).
legs(A, 7) :- fail.

insect(ant) :- true.
insect(bee) :- true.

 

Example
current_predicate(reverse/X). the goal succeeds twice with the substitutions:
X=1
X=2
current_predicate(X). the goal succeeds four times with the substitutions:
X=reverse / 1
X=reverse / 2
X=legs / 2
X=insect / 1
current_predicate(reverse/4). fails

 

Exceptions  
Term is neither a variable nor a predicate indicator pattern an type_error(predicate_indicator, Term) exception is thrown

 

 

info@trinc-prolog.com