|
|
1
1
您可以使用iso谓词“current_predicate/1”来找出可以调用的内容。 下面是一个示例程序: cat(tom).
animal(X) :- cat(X).
info(Arg,Info) :- current_predicate(PredName/1),
Info =.. [PredName,Arg], call(Info).
all_info(Arg,L) :- findall(I,info(Arg,I),L).
您可以使用以下程序(我使用的是sicstus prolog btw): | ?- info(tom,X). X = animal(tom) ? ; X = cat(tom) ? ; no | ?- all_info(tom,X). X = [animal(tom),cat(tom)] ? yes 一般来说,你可以使用 current_predicate如下: | ?- current_predicate(X). X = info/2 ? ; X = animal/1 ? ; X = cat/1 ? ; X = all_info/2 ? ; no |