list of curves in do-loop




On Wed, 16 Sep 2009, Gerhard Brunthaler wrote:

< Thanks a lot for you tip on plotting severeal curves with a loop at
< http://www.math.utexas.edu/pipermail/maxima/2006/002796.html
< 
< f(n) := block(
<     [curves : [], i],
<     for i:1 thru n do curves : cons(x^i, curves),
<     plot2d(curves, [x,-1,1])
< )$
< 
< It helped me already a lot, but I have a question in order to understand 
< what's going on.
< 
< Why the statement with i in:
< 
<  [curves : [], i], 

block([curves:[],i], ...)

sets up curves and i as variables local to the block, and initializes
curves to the empty list.

< 
< it works also with just: 
< 
<  curves : [], 

This creates curves as a global variable.


< 
< which creates an empty list. What is it good for to add the ", i]" ?
 
Since you probably don't need either variable outside of the block, it
makes sense to have them local variables.

This behaviour is documented in maxima's online help via

? function

or in section 39 of the user documentation.

Leo

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.