Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 370
bph Avatar asked Sep 01 '26 05:09

bph


1 Answers

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.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!