[sage-support] sum(.., n) doesn't work if n is a loop iterator.

2010-07-28 Thread sriram srinivasan
Can someone please shed light on this? The following works OK: k, n = var ('k n') sum(k, k, 1, 10) # ok. Gives 55 n = 10 sum(k, k, 1, n) # ok. Gives 55 But this gives an exception: for n in range(1,10): sum(k, k, 1, n) /Users/s/sw/sage/local/lib/python2.6/site-packages/sag

[sage-support] Re: sum(.., n) doesn't work if n is a loop iterator.

2010-07-28 Thread sriram srinivasan
I forgot to add: This too works OK. k, n = var('k n') sum(k, k, 1, n) # gives 1/2*n^2 + 1/2*n It fails only when n is a loop iterator. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com F

[sage-support] Re: sum(.., n) doesn't work if n is a loop iterator.

2010-07-28 Thread sriram srinivasan
Thanks much for your note. What surprises me is that sum() doesn't need coercion to sage integers when working with int-typed variables and numbers: sum(k, k, 1, 10) # ok n = 10; sum(k, k, 1, n)# ok I couldn't figure out the code path that looks for this difference. How does the sum 'kno

Re: [sage-support] Re: sum(.., n) doesn't work if n is a loop iterator.

2010-07-28 Thread Sriram Srinivasan
Ah, that solves the mystery. Thanks, Nils. As kcrisman suggested, functions should be able to automatically coerce ints to Sage Integers. --sriram. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@go