[eclipse-clp-users] how to solve this problem w/o non-logical variable?

From: Ulrich Scholz <wanderer_at_...190...>
Date: Fri, 10 Sep 2010 23:37:08 +0200
Dear all,

for the following problem I only can come up with a solution that uses a
non-logical variable.  I there a better way?

Consider I want to find all solutions of a predicate p.  At one point, there
is the choice between q and r, i.e.

p :- q.
p :- r.

>From studying the problem, I know that r can only have a solution if q had
(at least one) solution itself.  In other words, if q fails without ever
succeeding then r will fail, too.

The only way I see to prevent r from being tried is to set a non-logical
flag if q succeeds and let r fail in case the flag is unset.  

Of course, unsuccessfully trying r is so expensive that preventing it is
worth the effort.


Received on Fri Sep 10 2010 - 22:01:44 CEST

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