<< Back to previous view

[CLJ-764] (partition 0 seq) and (parition-all 0 seq) are infinite sequences of empty sequences Created: 21/Mar/11  Updated: 21/Jan/13

Status: Open
Project: Clojure
Component/s: None
Affects Version/s: Release 1.1, Release 1.2
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Paul Stadig Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

(partition n seq) and (partition-all n seq) are implemented by taking n and dropping n from seq. When n=0 this becomes an infinite sequence of empty sequences.

While conceptionally this makes sense, I think practically it may surprise people, and perhaps it should return an empty sequence or a sequence of a single empty sequence.



 Comments   
Comment by Paul Stadig [ 21/Mar/11 9:22 AM ]

Ugh! I didn't mean for this to be major priority, and I can't seem to edit it after the fact.

Comment by Mike Anderson [ 21/Jan/13 5:40 AM ]

I think the current behaviour is logically more correct than returning a empty sequence or a single empty sequence.

In particular, I would expect (partition n infinite-seq) to return an infinite sequence of sequences of length n, for any value of n >= 0. Anything else would be very surprising.

The only other sensible option would be throwing an exception, on the philosophical grounds that it isn't possible to partition a non-empty sequence into sub-sequences of length 0. But I think that changing behaviour in this way would break backwards compatibility for no obvious gain.

I suggest closing this issue.

Generated at Sat Oct 25 15:08:37 CDT 2014 using JIRA 4.4#649-r158309.