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

New circular Seq operations: rotateRight, rotateLeft, startAt #168

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

mcallisto
Copy link

@mcallisto mcallisto commented Jan 8, 2022

I would like to add to Seq several operations, all related to considering a Seq (or a subtype) a circular sequence.

If you take a look at my library repo at https://github.com/scala-tessella/ring-seq, these are all the methods that I have in mind.

But I started here adding just three, since I need to get used to the intricacies of the Scala collections.

If this is of interest, I will have many more questions on how to correctly add other methods.

@mcallisto
Copy link
Author

Any positive or negative comment about this proposal?

@SethTisue SethTisue requested a review from a team April 23, 2022 14:03
Comment on lines +113 to +115
def startAt[B >: seq.A, That](i: IndexO)(implicit bf: BuildFrom[C, B, That]): That =
rotateLeft(i)

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if this method should exists. When I have read its description, I though: but this is the same as rotateLeft. Once I have checked the implementation, I see it really just calls it.

Copy link
Author

Choose a reason for hiding this comment

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

@OndrejSpanel I can definitely see your point.

The reason why, at the end, I went for the proposed duplication is that startAt accepts an index, while rotateLeft accepts a number of steps. Even if the result is the same, depending on how you see the circular sequence both can feel more natural.

Just as an example, startAt plays nicely with reflectAt another method you can find in my more complete and documented RingSeq library, see https://scala-tessella.github.io/ring-seq/usage.html

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.

None yet

2 participants