You don't tell what you want to do with arrays, so that's just code to show how to loop.
let original = [1, 2, 3, 4, 5, 6]
var currentArray = original
print("currentArray =", currentArray) // Should do something more useful
var stop = false
repeat {
currentArray = currentArray.map() { ($0 + 2) % 25 + 1} // when $0 + 3 >= 26, we return to 1
print("currentArray =", currentArray) // Should do something more useful
stop = currentArray[0] == 25 // We stop when the array starts with 25, just to have a stop condition
} while !stop
Gives:
currentArray = [1, 2, 3, 4, 5, 6]
currentArray = [4, 5, 6, 7, 8, 9]
currentArray = [7, 8, 9, 10, 11, 12]
currentArray = [10, 11, 12, 13, 14, 15]
currentArray = [13, 14, 15, 16, 17, 18]
currentArray = [16, 17, 18, 19, 20, 21]
currentArray = [19, 20, 21, 22, 23, 24]
currentArray = [22, 23, 24, 25, 1, 2]
currentArray = [25, 1, 2, 3, 4, 5]
If you want to stop after having cycled, just change the stop condition:
let original = [1, 2, 3, 4, 5, 6]
var currentArray = original
print("original =", original) // Should do something more useful
var stop = false
repeat {
print("currentArray =", currentArray) // Should do something more useful
currentArray = currentArray.map() { ($0 + 2) % 25 + 1} // when $0 + 3 >= 26, we return to 1
stop = currentArray == original // We stop when the array starts with 1, which means we have looped back to original
} while !stop
yields:
original = [1, 2, 3, 4, 5, 6]
currentArray = [1, 2, 3, 4, 5, 6]
currentArray = [4, 5, 6, 7, 8, 9]
currentArray = [7, 8, 9, 10, 11, 12]
currentArray = [10, 11, 12, 13, 14, 15]
currentArray = [13, 14, 15, 16, 17, 18]
currentArray = [16, 17, 18, 19, 20, 21]
currentArray = [19, 20, 21, 22, 23, 24]
currentArray = [22, 23, 24, 25, 1, 2]
currentArray = [25, 1, 2, 3, 4, 5]
currentArray = [3, 4, 5, 6, 7, 8]
currentArray = [6, 7, 8, 9, 10, 11]
currentArray = [9, 10, 11, 12, 13, 14]
currentArray = [12, 13, 14, 15, 16, 17]
currentArray = [15, 16, 17, 18, 19, 20]
currentArray = [18, 19, 20, 21, 22, 23]
currentArray = [21, 22, 23, 24, 25, 1]
currentArray = [24, 25, 1, 2, 3, 4]
currentArray = [2, 3, 4, 5, 6, 7]
currentArray = [5, 6, 7, 8, 9, 10]
currentArray = [8, 9, 10, 11, 12, 13]
currentArray = [11, 12, 13, 14, 15, 16]
currentArray = [14, 15, 16, 17, 18, 19]
currentArray = [17, 18, 19, 20, 21, 22]
currentArray = [20, 21, 22, 23, 24, 25]
currentArray = [23, 24, 25, 1, 2, 3]