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 · 9 comments
Open

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

airspeedswift opened this issue Jan 3, 2018 · 9 comments
Assignees
Labels
feature A feature request or implementation good first issue Good for newcomers standard library Area: Standard library umbrella swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal

Comments

@airspeedswift
Copy link
Member

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

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

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

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
@AnthonyLatsis AnthonyLatsis added feature A feature request or implementation swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal and removed new feature StarterProposal labels Nov 11, 2022
@greenthings
Copy link

greenthings commented Oct 11, 2023

May i handle this issue?

please assign to me, I'll work on it and create a pull request!

@AnthonyLatsis
Copy link
Collaborator

@greenthings Please note that this feature needs a Swift evolution proposal.

@greenthings
Copy link

@AnthonyLatsis

Ok, thank you.

I'm going to make a proposal soon.

@injae-kim
Copy link

injae-kim commented Oct 26, 2023

apple/swift-evolution#2193

FYI, @greenthings make swift-evolution proposal~ I really want this sequence.lazy.split feature. thanks!

@greenthings
Copy link

greenthings commented Oct 26, 2023

Hi, @AnthonyLatsis , @airspeedswift

I have submitted a proposal for introducing lazy evaluation in Swift's Sequence. While the initial request was for implementing laziness in Sequence, I noticed that both Sequence and Collection could benefit from this feature. I'd appreciate guidance on whether I should create two separate proposals for 'Lazy Sequence' and 'Lazy Collection' or pursue a different approach."

Proposal URL:
apple/swift-evolution#2193

@AnthonyLatsis
Copy link
Collaborator

Hi Jun, a single proposal is fine. I assume your proposal is not ready for official review yet. Please turn apple/swift-evolution#2193 into a draft pull request until then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A feature request or implementation good first issue Good for newcomers standard library Area: Standard library umbrella swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal
Projects
None yet
Development

No branches or pull requests

5 participants