In the default case in this switch statement, I'm trying to iterate backwards in a for loop, there are examples of how to do this when working with Int's but I haven't found any with variables.
func arrayLeftRotation(myArray: [Int], d:Int) {
var newArray = myArray
switch d {
case 1:
let rotationValue = newArray.removeLast()
newArray.insert(rotationValue, at: 0)
default:
let upperIndex = newArray.count - 1
let lowerIndex = newArray.count - d
for i in lowerIndex...upperIndex {
let rotationValue = newArray.remove(at: i)
newArray.insert(rotationValue, at: 0)
}
}
print(newArray)
}
So I wish to count down from upperIndex to lowerIndex