[iterate-devel] destructively altering elements

Albert Krewinkel krewink at inb.uni-luebeck.de
Wed Jun 27 15:04:55 UTC 2007


Hello once more,

On Wed, Jun 27, 2007 at 04:11:36PM +0200, Hoehle, Joerg-Cyril wrote:
> Albert Krewinkel wrote:
> >> (for e in-matrix foo with-indices (i j))
> >That sure is a good way to do this.  Maybe you are right, and the
> >python zen "explizit is better than implicit" applies to this
> >situation as well. But I just feel like it's more verbose than
> >necessary.
> 
> To me it seems like "Iterate zen".  Otherwise you are with things like
> Series.  Actually, naming things simplifies (or make possible) some
> complex loops.

Seems reasonable; I'll try to adopt this.

> >  (iter (for el in-vector v with-index i)
> >        (setf (aref v i) 1))
> >the expansion code will contain (setq el (aref...)).
> The Iterate zen is for i index-of-vector.  See manual.
> That would not invoke aref.
> 
> The careful reader of the manual might expect
> (for nil in-vector ... with-index i) to avoid aref given a clever
> implementation, however Iterate is not Loop, so that construct does not
> work (yet?) with Iterate.

Looks like I have to re-read the manual more carefully. 


> Your code may appear to work for you, but your case expression is subtly
> broken.
> Please try
> (for el in-vector v by OR)
> (for el in-vector v by QUOTE)
D'OH! Thanks for pointing this out.

I will rewrite the driver using the `indices-of..' idiom.  I don't
really see the advantages yet, but that's probably due to a lack of
experience on my side.

Thanks again the help and for your time,

Best
Albert



More information about the iterate-devel mailing list