Path: 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 > 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.'