Re: Iteration with named let

Subject: Re: Iteration with named let
From: Dave Love <d.love@xxxxxxxx>
Date: 25 Jun 1997 20:48:09 +0100
>>>>> "Henry" == Henry S Thompson <ht@xxxxxxxxxxxxxxx> writes:

 Henry> People have already replied about a one-line way to do this.

 Henry> There is at least an infelicity in your style, at worst a bug,
 Henry> which given your gracious willingness to be coached I'll
 Henry> tackle -- usually in let loops you do the loop check at the
 Henry> top:

 Henry> (let loop ((desc-list (children %element%)))
 Henry>      (if (node-list-empty? desc-list)
 Henry> 	 #f
 Henry>        (or (equal? (gi (node-list-first desc-list))
 Henry> 		   %gi%)
 Henry> 	   (loop (node-list-rest desc-list)))))

It may also be worth noting that there are higher-order standard
functions like `node-list-some?' that capture patterns of computation
like this.

If they're not primitive they can be coded and re-used in best
functional programming style (without having to think out the
recursion, which is normally the Right Thing).  [At least, I think
they can be coded up for Jade now there's a node-list constructor;
certainly the normal list equivalents can and might be useful.]

 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread