12 lines
230 B
Swift
12 lines
230 B
Swift
|
import Foundation
|
||
|
|
||
|
extension Array {
|
||
|
|
||
|
func rotated(toStartAt index: Int) -> [Element] {
|
||
|
guard index != 0 else {
|
||
|
return self
|
||
|
}
|
||
|
return Array(self[index..<count] + self[0..<index])
|
||
|
}
|
||
|
}
|