Details
-
Type:
Defect
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: Release 1.1, Release 1.2, Release 1.3, Release 1.4, Release 1.5
-
Fix Version/s: Release 1.5, Release 1.6
-
Component/s: None
-
Patch:Code and Test
-
Approval:Ok
Description
Problem statement: The current behavior of range is inconsistent. (range 0 9 0) has always produced (). (range 0 9 -1) has always produced (). (range 9 0 1) has always produced (). However, (range 9 0 0) produces (9 9 9 9 ...), and (range 0 0 0) produces '(0 0 0 0 ...)
Proposal: Make the behavior of range consistent when using a step of 0 to make it produce an empty list.
Please see attached code and patch.
Attachments
Activity
Devin Walters
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Attachment | range.clj [ 11353 ] | |
| Attachment | fix_zero_step_range.patch [ 11352 ] |
Devin Walters
made changes -
| Attachment | inconsistent_range_fix.diff [ 11393 ] |
Timothy Baldridge
made changes -
| Assignee | Devin Walters [ devn ] | Timothy Baldridge [ halgari ] |
Timothy Baldridge
made changes -
| Approval | Vetted [ 10003 ] | |
| Fix Version/s | Release 1.5 [ 10150 ] | |
| Fix Version/s | Backlog [ 10035 ] |
Timothy Baldridge
made changes -
| Approval | Vetted [ 10003 ] | Screened [ 10004 ] |
Timothy Baldridge
made changes -
| Assignee | Timothy Baldridge [ halgari ] |
Timothy Baldridge
made changes -
| Fix Version/s | Backlog [ 10035 ] | |
| Fix Version/s | Approved Backlog [ 10034 ] |
Devin Walters
made changes -
| Attachment | fix_zero_step_range.patch [ 11352 ] |
Devin Walters
made changes -
| Attachment | range.clj [ 11353 ] |
Rich Hickey
made changes -
| Approval | Screened [ 10004 ] | Ok [ 10007 ] |
| Fix Version/s | Approved Backlog [ 10034 ] | |
| Fix Version/s | Release 1.5 [ 10150 ] | |
| Fix Version/s | Release 1.6 [ 10157 ] |
Agree it is good to fix the inconsistency, but I think an infinite sequence of zeros is the correct result, as implied by the current docstring definition.
It's also mathematically cleanest: range should produce an arithmetic progression until the end value is equalled or exceeded.
Empty lists only seem to make sense as a return value when start >= end.