Skip to content

Instantly share code, notes, and snippets.

@jasdev
Created March 14, 2021 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasdev/35802ac2b5681d9b6c5ca2ee6928fd7b to your computer and use it in GitHub Desktop.
Save jasdev/35802ac2b5681d9b6c5ca2ee6928fd7b to your computer and use it in GitHub Desktop.
Collection.rotated(toStartAt:).
extension Collection where SubSequence: RangeReplaceableCollection {
func rotated(toStartAt newStart: Index) -> SubSequence {
self[newStart...] + self[..<newStart]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment