How about providing a sum function that would behave like, say, the
integrate function.  It could detect the argument types so if you
passed it a list, it'd behave the same as the builtin sum function.

sage: integrate(x, x, 0, 10)
50
sage: sum(x, x, 0, 10)
55
sage: sum(range(10))
45

I'm having trouble thinking of other instances where range() not
including the upper bound would cause (major) problems.

--Mike

On 9/18/07, Jaap Spies <[EMAIL PROTECTED]> wrote:
>
> Robert Bradshaw wrote:
>
> >> Why not define a new function srange (short for sagerange),
> >> or redefine the existing srange function:
> >>
> >> def srange(a,b=None,step=1, include_endpoint=True):
> >>
> >> or something like that.
> >>
> >> See sage: srange??
> >>
> >> Alternative: reuse xrange
> >> this function will be removed from Python in Python3000.
> >
> > One disadvantage of this is that include_endpoint=True takes much
> > more time to write than "+1", and requires the same amount of
> > knowledge. Perhaps one could have a function "full_range" that
> > includes the endpoint.
>
> Sorry, I meant this to be the default action.
>
> Jaap
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@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-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to