On Sep 21, 2007, at 10:29 AM, Hamptonio wrote: > The relevant codeblock from misc/misc.py is: > > if include_endpoint: > if universe in [int, long, ZZ]: > if (start-end) % step == 0: > end += step > elif (start-end)/step in ZZ: > end += step > > which looks a little funny to me in general; in this specific case of > course universe=None and (start-end)/step is a RealNumber so the > endpoint is left unchanged. I'm not sure what would be wrong with > just having > > if include_endpoint: > end += step > > but maybe the author (William S. or Robert B.?) had a reason I can't > think of.
This is because srange(1,10,2) shouldn't include 10 whether or not include_endpoint is true. It's a question of landing exactly on the endpoint (thought the above code is wrong because floats are never in ZZ, so I've just done int(x) == x. I have also neglected (so far) to handle a couple of other cases (e.g. when elements are uncomparable but (start-end)/step is still an int like for CC). - Robert > > -Marshall > > On Sep 21, 7:59 am, Jaap Spies <[EMAIL PROTECTED]> wrote: >> The new (fast) srange function with include_endpoint=True >> dus not include the endpoint in some cases: >> >> sage: srange(1.0, 5.0, include_endpoint=True) >> [1.00000000000000, 2.00000000000000, 3.00000000000000, >> 4.00000000000000] >> >> Jaap > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] 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/ -~----------~----~----~----~------~----~------~--~---
