🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3963

Re: Committed Choice

#3963
From: Paul Broome
Date: Thu, 23 Mar 1989 17:09
46 lines
1850 bytes
Here's one alternative I've seen that's only slightly cleaner:  Define

	repeat(Body,Until) :-
		repeat,
		Body,
		Until,
		!.
		
Then we can accomplish the same thing with

	...
	repeat(<continue condition>, <exit condition>).
	

-Paul


In article <8209@russell.STANFORD.EDU> pereira@russell.UUCP (Fernando Pereira) writes:
:In Edinburgh-family Prolog systems, the scope of a cut is the whole
:clause in which it appears, even it the cut is inside a conditional.
:This is a very useful control behavior, messy to simulate with cuts
:that stay inside the scope of conditionals. For example, the following
:is a common way of terminating a repeat/fail loop:
:
:	...
:	repeat,
:		...
:		( <exit condition> -> !
:		; <continue condition> -> fail ).
:
:I will agree with anybody that this is not a pristine example of
:declarative programming, but such things *are* needed in the imperfect
:logic-programming languages we have today. I also appreciate that we
:could move the cut to after the conditional with the same result, but
:there are more complicated situations, which I don't have the time now
:to discuss, in which that alternative is not available.
:
:Fernando Pereira
:AI Center
:SRI International
:pereira@ai.sri.com



Paul Broome
broome@brl.arpa
Technical Details
Message-ID: <18798@adm.BRL.MIL>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ucsd!rutgers!cmcl2!adm!broome
References: <11500012@hpldola.HP.COM> <733@gould.doc.ic.ac.uk> <1305@murtoa.cs.mu.oz.au> <8209@russell.STANFORD.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ucsd!rutgers!cmcl2!adm!broome
From: broome@adm.BRL.MIL (Paul Broome )
Newsgroups: comp.lang.prolog
Subject: Re: Committed Choice
Keywords: cut if-then-else
Message-ID: <18798@adm.BRL.MIL>
Date: 23 Mar 89 17:09:20 GMT
References: <11500012@hpldola.HP.COM> <733@gould.doc.ic.ac.uk> <1305@murtoa.cs.mu.oz.au> <8209@russell.STANFORD.EDU>
Reply-To: broome@brl.arpa (Paul Broome (CSMB) <broome>)
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 46