Re: [eclipse-clp-users] saving the resolution list of a call

From: Marco Gavanelli <marco.gavanelli_at_...17...>
Date: Fri, 14 May 2010 17:56:11 +0200
Christian Wirth wrote:
> Hi,
> i also need to save the resolution list of a call, meaning a list of all 
> called predicates in the called order (without and/or, but that could be 
> extracted later).
> Something like this (only an example, not tested):
> rescall(true,_) :- !.
> rescall((A,B),Res) :- rescall(A,Res),rescall(B,Res).
> rescall((A;B),Res) :- rescall(A,Res);rescall(B,Res).
> rescall(X,Res) :- 
> not(booleanfunctor(X)),functor(X,F,A),member(F/A,Res),clause(X,C),rescall(C,Res).

This member looks definitely slow, as each time it has to scan the whole 
Res list from the beginning.

Why not

rescall(X,[F/A|Res]) :-

Of course, then you have to change something in the other clauses as 
well. You could use something like append (but adapted for difference 
lists) in the clause:

rescall((A,B),Res) :- rescall(A,Res),rescall(B,Res).

but then you would be again scanning the list from the beginning.

So, you could make available the variable that terminates the difference 
list as another parameter:

rescall(true,X,X):- !.
rescall((A,B),Res,END) :-
	rescall(A,Res,EndTemp), rescall(B,EndTemp,END).

% Here I am not sure I understand what you want:
% rescall((A;B),Res) :- rescall(A,Res);rescall(B,Res).

rescall(X,[F/A|Res],End) :-


Marco Gavanelli, Ph.D. in Computer Science
Dept of Engineering
University of Ferrara
Tel/Fax  +39-0532-97-4833
Received on Fri May 14 2010 - 15:56:21 CEST

This archive was generated by hypermail 2.3.0 : Tue May 14 2019 - 03:13:24 CEST