Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!godot.cc.duq.edu!news.duke.edu!convex!cs.utexas.edu!howland.reston.ans.net!EU.net!sun4nl!freya.let.rug.nl!vannoord
From: vannoord@let.rug.nl (Gertjan van Noord)
Subject: Re: succeeding always
Sender: news@let.rug.nl (News system at let.rug.nl)
Message-ID: <1994Sep30.092815.3816@let.rug.nl>
Date: Fri, 30 Sep 1994 09:28:15 GMT
References:  <geoff.780888565@coral.cs.jcu.edu.au>
Nntp-Posting-Host: vidar.let.rug.nl
Organization: Faculteit der Letteren, Rijksuniversiteit Groningen, NL
Keywords: success
Lines: 37

In article <geoff.780888565@coral.cs.jcu.edu.au>, geoff@coral.cs.jcu.edu.au (Geoff Sutcliffe) writes:
> This must be simple ... I have a goal which may or may not succeed (in only
> one way), but I want it to always succeed in a certain context. If the goal 
> is p/0, one way to do it is:
>     p -> true;true.
> I'm sure there must be a better way! Any suggestions? 

I don't think there is a better way. If you happen to use Sicstus
another useful predicate is if/3 which can also be used if your p
predicate might succeeds more than once.

if(P,Q,R)

is, I think, equivalent with

( P, Q ; \+ P, R)

so in you case you would have 
if(P,true,true)

Gertjan van Noord,   Alfa-informatica RUG
Postbus 716,         NL 9700 AS Groningen
tel. +31 50 635935   fax  +31 50 634900
vannoord@let.rug.nl  http://tyr.let.rug.nl/~vannoord



> 
> Geoff Sutcliffe
> Department of Computer Science    Email : geoff@cs.jcu.edu.au
> James Cook University             Phone : +61 77 815085/814622
> Townsville, Australia, 4811.      FAX   : +61 77 814029
> --
> Geoff Sutcliffe
> Department of Computer Science    Email : geoff@cs.jcu.edu.au
> James Cook University             Phone : +61 77 815085/814622
> Townsville, Australia, 4811.      FAX   : +61 77 814029
