2

Is it possible to pose a query such as

?- X(C). 

that can return all the predicates that have arity 1? In general, is it possible to refer to a predicate name by using a variable?

false
  • 10,264
  • 13
  • 101
  • 209
Roberta G
  • 23
  • 2

1 Answers1

4

current_predicate(X/1). shows predicates with arity 1.

You can use call to call a goal from a variable.

Sergii Dymchenko
  • 6,890
  • 1
  • 21
  • 46
  • As pointed out [here](http://stackoverflow.com/questions/14494146/search-for-a-atom-in-prolog), `current_predicate` is SWI-specific. Is there a more general way? – Daniel Lyons Feb 08 '13 at 07:07
  • 1
    In the linked question user false says that `current_functor/2` is SWI-specific, not `current_predicate/1`. I think `current_predicate/1` is in ISO. I checked in 5 Prolog systems I have installed, and all of them have `current_predicate/1`. – Sergii Dymchenko Feb 08 '13 at 07:26
  • @Dan: Sergii is right. For some time, I try to add [this link](http://www.complang.tuwien.ac.at/ulrich/iso-prolog/prologue#status_quo) or [this](http://stackoverflow.com/a/10914371/772868) to [the tag description of ISO Prolog](http://stackoverflow.com/tags/iso-prolog/info) but I have no luck: t is rejected all the time... – false Feb 10 '13 at 16:58