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

[RFC] Add eachrsplit iterator #51646

Merged
merged 1 commit into from
Oct 11, 2023
Merged

Conversation

jakobnissen
Copy link
Contributor

@jakobnissen jakobnissen commented Oct 9, 2023

Unlike rsplit, this iterator returns split substrings right to left, but other- wise it behaves just like eachsplit.
This design has been chosen to avoid either a costly double traversal of the input string, or needing a stack to store the strings. Both of these workarounds would lessen the appeal compared to simply using rsplit.

Closes #45385

Request for comments

  • Is it acceptable that it returns the substrings in reverse order compared to rsplit? I believe this is unfortunately necessary.

@jakobnissen jakobnissen added needs compat annotation Add !!! compat "Julia x.y" to the docstring kind:feature Indicates new feature / enhancement requests domain:strings "Strings!" domain:iteration Involves iteration or the iteration protocol labels Oct 10, 2023
@jakobnissen jakobnissen removed the needs compat annotation Add !!! compat "Julia x.y" to the docstring label Oct 10, 2023
@jakobnissen jakobnissen marked this pull request as ready for review October 10, 2023 08:47
@jakobnissen jakobnissen force-pushed the eachrsplit branch 2 times, most recently from 7967578 to 0ea52a5 Compare October 10, 2023 09:30
Unlike rsplit, this iterator returns split substrings right to left, but other-
wise it behaves just like eachsplit.
This design has been chosen to avoid either a costly double traversal of the
input string, or needing a stack to store the strings. Both of these workarounds
would lessen the appeal compared to simply using rsplit.
@jakobnissen
Copy link
Contributor Author

Squashed, otherwise unchanged. I think the ASAN build failure is unrelated to this PR.

@jakobnissen jakobnissen added the status:merge me PR is reviewed. Merge when all tests are passing label Oct 11, 2023
@vtjnash vtjnash merged commit be1702e into JuliaLang:master Oct 11, 2023
5 of 7 checks passed
@oscardssmith oscardssmith removed the status:merge me PR is reviewed. Merge when all tests are passing label Oct 11, 2023
@jakobnissen jakobnissen deleted the eachrsplit branch October 11, 2023 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:iteration Involves iteration or the iteration protocol domain:strings "Strings!" kind:feature Indicates new feature / enhancement requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add eachrsplit iterator
3 participants