Path: utzoo!mnetor!uunet!husc6!sri-unix!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: mine embarrassingly simple problem Message-ID: <796@cresswell.quintus.UUCP> Date: 23 Mar 88 01:16:54 GMT References: <500@taux01.UUCP> <764@cresswell.quintus.UUCP> <503@taux01.UUCP> <512@taux01.UUCP> Organization: Quintus Computer Systems, Mountain View, CA Lines: 55 In article <512@taux01.UUCP>, shahaf@taux01.UUCP (Shahaf Moshe) writes: > The program looks like: > > map(Function,Network) :- > generate(Function,Network), > test(Network). > test(Network) :- > lemma(Network,StopCondition), > !(map). %this cut aborts the process. > In that case, why not just code it as map(Function, Network) :- generate(Function, Network), test(Network), !. test(Network) :- lemma(Network, StopCondition). More generally, suppose that you had several cases: test(Network) :- lemma(Network, ~~~), !(map(_,_)), p(...). ... test(Network) :- lemma(Network, ~~~), !(map(_,_)), q(...). Then you could recast this as map(Function, Network) :- generate(Function, Network), test(Network, Continuation), !, finish(Continuation, ...). finish(p, ...) :- p(...). ... finish(q, ...) :- q(...). test(Network, p) :- lemma(Network, ~~~). ... test(Network, q) :- lemma(Network, ~~~). The basic idea is to redesign your "test" code so that it breaks into three pieces: before-the-cut, the ancestral cut, and after-the-cut, and then unfold the call to it so that the cut is exposed in "map".