Re: [eclipse-clp-users] Backtracking over current predicate only

From: Joachim Schimpf <joachim.schimpf_at_...44...>
Date: Sat, 15 May 2010 21:22:14 +1000
Christian Wirth wrote:
> Hi,
> 
> how can i define a cut that allows backtracking over the current 
> predicate but not over another predicate ?
> example:
> 
> pred(aPred(X)) :- call(X).
> pred(X) :- anotherCall(X).
> 
> i now want to define a cut that creates all solutions for call(X), if 
> the first perdicate gets matched, but it should prevent matching the 
> other one.
> I'm currently using pred(X) :- 
> functor(X,F,A),not(F==aPred),anotherCall(X), but i want to replace this 
> because speedup is very essential.
> 
> .. hope this is possible.

It sounds like all you want is

pred(aPred(X)) :- !, call(X).
pred(X) :- anotherCall(X).

You can find these basics in any introductory Prolog text.  We have a
few links on the web site http://eclipse-clp.org/links.html

-- Joachim
Received on Sat May 15 2010 - 11:22:23 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST