Hello group,

Is it possible to have the variables that appear in "for" loops and
other such constructs to be "dummy" in the mathematical sence
(probably the cs term is "local")?  The current behavior, in which
after the loop is completed the loop variable is _still_ set to the
last value it assumed, is very confusing -- at least to me.  For
example, it took me some time to realize the mistake in the follow
sequence of commands:

f(x) = sin(x)/x
for x in [1.0/2^i for i in range(1,15)]:
    print x, f(x)

for x in [-1.0/2^i for i in range(1,15)]:
    print x, f(x)

plot(f(x), -1, 1)

I believe that a lot of mathematicians and students will be confused
by this behavior.  At least for the Calculus part I think that it
would be a good idea to have a "mathematical for" in which the
looping variable is automatically reset after the completion of the
loop. IMHO, this is more in agreement with common mathematical
practice.
 
FWIW,
Nikos


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to