Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-6691] Sequence.split should have a Lazy equivalent #49240

Open
airspeedswift opened this issue Jan 3, 2018 · 3 comments
Open

[SR-6691] Sequence.split should have a Lazy equivalent #49240

airspeedswift opened this issue Jan 3, 2018 · 3 comments

Comments

@airspeedswift
Copy link
Member

airspeedswift commented Jan 3, 2018

Previous ID SR-6691
Radar None
Original Reporter @airspeedswift
Type New Feature
Status In Progress
Resolution
Additional Detail from JIRA
Votes 4
Component/s Standard Library
Labels New Feature, StarterBug, StarterProposal
Assignee None
Priority Medium

md5: 1e8d36124b9916625ca75e3f19b449dc

Issue Description:

Sequence.split is eager, but if you are splitting a collection, it should be possible to do it lazily. This could be done via an extension to LazyCollectionProtocol so you could write "a.b.c".lazy.split(separator: ".").

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 22, 2018

Comment by Daryle Walker (JIRA)

It seems this bug may have been inspired by the blog post "Conditional Conformance in the Standard Library". On a Swift mailing-list thread, I had a conversation with the author over a similar class. In my final code, I wrote:

  • An iterator that chunks another

  • A sequence that chunks another

  • A sequence that chunks a collection

  • A collection that chunks another

The blog only has something like the last one. But all four may be useful when porting to the standard library. (The first two types vend an Array of Element, the latter two SubSequence.)

Edit: looking at the blog post again, I noticed that his example splits on a given separator value, while my code splits after a set count of elements.

Edit 2: He does mention a chunking collection at the end of the blog post.

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 23, 2018

Comment by Tapan Thaker (JIRA)

CTMacUser (JIRA User) : Based on your comment shall I sure that you are working on this ?
I wanted to start contributing to Swift so thought this started task would be apt for me to get started.

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 26, 2018

Comment by Daryle Walker (JIRA)

I came up with the idea to help break up a Mac-specific collection (NSData), then for play. I wasn't thinking of it as a Swift standard library contribution. I don't know what to do here because I'm distracted by another Swift idea (which happens to me a lot). So, if you want to work on chunking (and/or splitting) yourself, go ahead.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants