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

From: Ulrich Scholz <wanderer_at_thispla.net>
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.

Thanks,

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

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET