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

Reverse slices and inequality slices with implicit parts #1478

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

edemaine
Copy link
Collaborator

This was mostly for fun, and for code golfers to be able to reverse a string with x[..>=]. It ended up a little bigger than I expected, to get the many cases working...

  • Slices remain increasing by default (even without </<= modifier)
  • With explicit > or >=, slices are reversed, similar to a range, so normally left ≥ right. For example, x[..>=] is equivalent to x[-1 ..>= 0] which is equivalent to x[x.length - 1 ..>= 0]
  • Also fix increasing slices with implicit parts, like x[..<]

Copy link
Contributor

@STRd6 STRd6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Golfers are going to go nuts over x[..<=]

@edemaine edemaine merged commit 1c74a32 into main Oct 21, 2024
4 checks passed
@edemaine edemaine deleted the reversed-slice branch October 21, 2024 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants