🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #4171

Re: loops in prolog

#4171
From: Ken Johnson
Date: Sat, 10 Feb 1990 21:49
33 lines
1111 bytes
> Question: how would you code the following loop in (Edingburgh)
> Prolog?
>
>loop:
>   action_1;
>   IF condition_1 THEN
>     action_2;
>     goto loop
>  END IF
>  action_3;

Answer

loop :-
	action1,
	loop1.

loop1 :-
	condition1,
	!,
	action2,
	loop.

loop1 :-
	action3.

Any other homework you want done, just post it. 

-- 
Ken Johnson, AI Applications Institute, 80 South Bridge, Edinburgh EH1 1HN
E-mail ken@aiai.ed.ac.uk, phone 031-225 4464 extension 212
`I have read your article, Mr Johnson, and I am no wiser now than when I
started'.  -- `Possibly not, sir, but far better informed.'
Technical Details
Message-ID: <1728@skye.ed.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!mcsun!ukc!edcastle!aiai!ken

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!mcsun!ukc!edcastle!aiai!ken
From: ken@aiai.ed.ac.uk (Ken Johnson)
Newsgroups: comp.lang.prolog
Subject: Re: loops in prolog
Keywords: loops
Message-ID: <1728@skye.ed.ac.uk>
Date: 10 Feb 90 21:49:19 GMT
Reply-To: ken@aiai.UUCP (Ken Johnson)
Organization: AIAI, University of Edinburgh, Scotland
Lines: 33