🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #565

Re: general PROLOG questions

#565
From: Andrew Taylor
Date: Sun, 10 Dec 1989 22:54
15 lines
1041 bytes
>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
Technical Details
Message-ID: <661@cluster.cs.su.oz>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!basser!cluster!andrewt
References: <5631@uhccux.uhcc.hawaii.edu> <2898@munnari.oz.au> <793@fs1.ee.ubc.ca> <10231@alice.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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