Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!news.sei.cmu.edu!cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!spool.mu.edu!sgiblab!brunix!cs!rv
From: rv@fiji.cs.brown.edu (rodrigo vanegas)
Subject: Re: Tcl/Lisp/Python: A "User" point of view
In-Reply-To: bevan@cs.man.ac.uk's message of 04 Oct 1994 16:08:33 GMT
Message-ID: <RV.94Oct4124444@fiji.cs.brown.edu>
Sender: news@cs.brown.edu
Organization: Brown University Department of Computer Science
References: <9409232314.AA29957@mole.gnu.ai.mit.edu> <Cww0DA.I68@cwi.nl>
	<BLUME.94Sep29094838@beth.cs.princeton.edu>
	<36hn4v$ak6@csnews.cs.Colorado.EDU> <36jl5v$6dc@news.cs.tu-berlin.de>
	<BLUME.94Oct1153023@beth.cs.princeton.edu>
	<BEVAN.94Oct4170833@lemur.cs.man.ac.uk>
Date: Tue, 4 Oct 1994 16:44:44 GMT
Lines: 42

In article <BEVAN.94Oct4170833@lemur.cs.man.ac.uk> bevan@cs.man.ac.uk (Stephen J Bevan) writes:

   In article <BLUME.94Oct1153023@beth.cs.princeton.edu> blume@beth.cs.princeton.edu (Matthias Blume) writes:
      using `do':

      (do ((i 0 (+ i 1))
	   (l '() (cons i l)))
	  ((>= i 10000) l))

      using a `named let':

      (let loop
	  ((i 0)
	   (l '()))
	(if (>= i 10000)
	    l
	    (loop (+ i 1) (cons i l))))

      as a tail-recursive procedure:

      (letrec ((loop (lambda (i l)
		       (if (>= i 10000)
			   l
			   (loop (+ i 1) (cons i l))))))
	(loop 0 '()))

      My guess is that to the untrained eye the first (`do'-based) version
      is the most compact one.


I would write the named let like this

   (let next ((i 0) (l '()))
     (if (>= i 10000) l
       (next (+ i 1) (cons i l))))

and needless to say, i find it the most readable of the four.


rodrigo vanegas
rv@cs.brown.edu

