🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #4304

Re: PROLOG in the "real" world?

#4304
From: Charles R. Martin
Date: Wed, 09 Oct 1991 03:12
38 lines
3226 bytes
In article <benanav.686887869@earth.njit.edu> benanav@earth.njit.edu (Dan Benanav) writes:

   clin@eng.umd.edu (Charles Lin) writes:

   >    While I personally like the idea of recursion and use it whenever I program
   >in LISP, I am curious to other reasons of using recursion besides elegance.


   It's not just a matter of elegance.  I find it much easier to write
   resursive programs.   I can write a recursive version of an
   algorithm  much faster then the iterative version.

I've just been working away on a hand-proven program (anyone still
remember me promising to have a TR about doing this?  I'm *finally*
getting around to finishing it.  Don't ask why.)  and, anyway, noticed
something rather neat: often, I can use a recursive program to identify
the appropriate bound and invariant for an iterative program; of course,
once one has both coding the loop itself is trivial.  (Except when it
isn't, of course.)

In any case, I suspect that which is more "natural" is largely based on
experience, and often depends on what your first experience was.  If you
-- as I did -- wrote your first tree-searching routines in Fortran II,
you will probably always have an inclination to use iteration;
similarly, if you grew up in a Lisp environment, you will gravitate to
recursion.  I also share Dijkstra's distaste for a fixation on recursion
so strong that the definition of a while..do is resolved to be a
recursive call.

In any case, I think that it's incumbent on programmers to try to learn
to use BOTH recursion and iteration naturally and readily, so that
both are available parts of the tool bix.
--
Charles R. Martin/(Charlie)/martinc@cs.unc.edu/(nee crm@cs.duke.edu) 
O/Department of Computer Science/Sitterson Hall/UNC/Chapel Hill, NC 27599
H/13 Gorham Place/Durham, NC 27705/(919) 383-2256
		"This universe is full of magical things
	    patiently waiting for our wits to grow sharper"
Technical Details
Message-ID: <MARTINC.91Oct8231255@hatteras.cs.unc.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cs.utexas.edu!swrinde!gatech!mcnc!borg!news_server!martinc
References: <1991Oct02.193655.16492@chome.ruhr.de> <1991Oct3.180209.3023@athena.cs.uga.edu> <1991Oct04.142838.29652@eng.umd.edu> <1991Oct4.173827.14992@athena.cs.uga.edu> <1991Oct07.133749.15786@eng.umd.edu> <benanav.686887869@earth.njit.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f43e6,2ad8401e5c040397
X-Google-Attributes: gidf43e6,public
X-Google-Thread: f907c,2ad8401e5c040397
X-Google-Attributes: gidf907c,public
X-Google-Thread: 102449,2ad8401e5c040397
X-Google-Attributes: gid102449,public
X-Google-Thread: 10461e,2ad8401e5c040397
X-Google-Attributes: gid10461e,public
X-Google-Thread: 10db24,2ad8401e5c040397
X-Google-Attributes: gid10db24,public
X-Google-ArrivalTime: 1991-10-09 15:14:50 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cs.utexas.edu!swrinde!gatech!mcnc!borg!news_server!martinc
From: martinc@hatteras.cs.unc.edu (Charles R. Martin)
Newsgroups: comp.lang.prolog,comp.software-eng,comp.edu,comp.ai,aus.ai
Subject: Re: PROLOG in the "real" world?
Message-ID: <MARTINC.91Oct8231255@hatteras.cs.unc.edu>
Date: 9 Oct 91 03:12:55 GMT
References: <1991Oct02.193655.16492@chome.ruhr.de> <1991Oct3.180209.3023@athena.cs.uga.edu>
 <1991Oct04.142838.29652@eng.umd.edu>
 <1991Oct4.173827.14992@athena.cs.uga.edu>
 <1991Oct07.133749.15786@eng.umd.edu> <benanav.686887869@earth.njit.edu>
Sender: news@cs.unc.edu
Followup-To: comp.lang.prolog
Organization: /theta/theta5/unc/martinc/.organization
Lines: 38
In-reply-to: benanav@earth.njit.edu's message of 8 Oct 91 02:11:09 GMT