Ticket #110 (closed enhancement: fixed)
srange should accept negative step value
| Reported by: | dmharvey | Owned by: | somebody |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | basic arithmetic | Keywords: | |
| Cc: | Author(s): | ||
| Report Upstream: | Reviewer(s): | ||
| Merged in: | Work issues: |
Description
It should work more like Python's ordinary range, not like this:
sage: srange(1, 5, -1)
---------------------------------------------------------------------------
exceptions.ValueError Traceback (most recent call last)
/home/dmharvey/sage-1.3.7.3.3/<ipython console>
/home/dmharvey/sage/local/lib/python2.4/site-packages/sage/misc/misc.py in srange(a, b, step, include_endpoint)
630
631 if step <= 0:
--> 632 raise ValueError, "step (=%s) must be positive"%step
633 num_steps = int(float((b-a)/step)) + 1
634 v = [a] + [a + k*step for k in range(1,num_steps)]
ValueError: step (=-1) must be positive
Change History
Note: See
TracTickets for help on using
tickets.
