bph
bph

Reputation: 11258

Listing predicates within a given library module

Is there a means to list all the predicates that are defined in a given library module for SICStus Prolog?

e.g. if I load the lists module:

| ?- use_module(library(lists)).

is there another predicate I can run from the prompt to tell me what predicates have just been imported?

Upvotes: 3

Views: 211

Answers (1)

user1812457
user1812457

Reputation:

This works with SWI-Prolog, but the predicate current_predicate/1 is marked as "ISO" so at least give it a try in SICSTUS. Here is what I get:

?- use_module(library(lists)).
true.

?- current_predicate(lists:P).
P = max_list/3 ;
P = flatten/2 ;
% and so on

Or maybe:

?- findall(P, current_predicate(lists:P), Ps).
Ps = [max_list/3, flatten/2, nth1/4, reverse/4, must_be/2, min_member_/3, reverse/2, transpose_pairs/2, ... / ...|...].

You should be able to do this in any Prolog that implements current_predicate/1.

Upvotes: 4

Related Questions