Bash Cyclic Rotation
cyclic_rotation() {
    local -n _a="$1"
    local -n _out="$2"
    local _k=$3
    local _size=${#_a[@]}
    if (( _size == 0 )); then
        _out=()
        return
    fi
    _k=$(( _k % _size ))
    _out=()
    local _i
    for ((_i = 0; _i < _size; _i++)); do
        _out[(_i + _k) % _size]=${_a[_i]}
    done
}

This rotates the array to the right by K steps and keeps the wrap-around values in the correct order.