[CLJ-1117] Partition does not follow docs Created: 29/Nov/12 Updated: 17/May/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.6 |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Minor |
| Reporter: | Timothy Baldridge | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
OS X, 10.8 |
||
| Attachments: |
|
| Patch: | Code |
| Description |
|
The doc for partition states "In case there are not enough padding elements, return a partition with less than n items." However, the behavior of this function is as follows: user=> (partition 3 (range 10)) Either the doc should be updated to make it clear that not providing a pad will mean that items are dropped, or the functionality of partition should be fixed to the following: user=> (partition 3 (range 10)) |
| Comments |
| Comment by Andy Fingerhut [ 29/Nov/12 2:15 PM ] |
|
That would be a potentially breaking change for some people's code that uses partition. partition-all behaves as you wish. Also, your concern with the documentation is for when there are padding elements specified as an argument, but your examples don't specify any padding elements. |
| Comment by Timothy Baldridge [ 29/Nov/12 2:55 PM ] |
|
I agree, but I think the docs should then explicitly state: "if no padding is given, not all input elements may be returned in the output partitions" or something to that line. |
| Comment by Andy Fingerhut [ 29/Nov/12 4:43 PM ] |
|
More precise documentation of current behavior is always welcome in my opinion. |
| Comment by Gabriel Horner [ 17/May/13 10:14 AM ] |
|
I've uploaded a patch that calls out when and how partition drops tail elements: |