Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!basser!cluster!andrewt From: andrewt@cs.su.oz (Andrew Taylor) Newsgroups: comp.lang.prolog Subject: Re: general PROLOG questions Keywords: choicepoint Message-ID: <661@cluster.cs.su.oz> Date: 10 Dec 89 22:54:09 GMT References: <5631@uhccux.uhcc.hawaii.edu> <2898@munnari.oz.au> <793@fs1.ee.ubc.ca> <10231@alice.UUCP> Sender: news@cluster.cs.su.oz Reply-To: andrewt@cluster.cs.su.oz (Andrew Taylor) Organization: Basser Dept of Computer Science, University of Sydney, Australia Lines: 15 >nth(1, [Elem|_], Elem). >nth(I, [_|Rest], Elem) :- > I > 0, > J is I - 1, > nth(J, Rest, Elem). > >If your Prolog leaves an extraneous choice point when succeeding at the >base case (as unfortunately most will), a cut may be used for efficiency If the I > 0 is changed to I > 1 (as was probably meant) its easy to detect that no choicepoint is needed. Can anybody's prolog compiler/analyser detect this without the change? Andrew Taylor