/**
 * Modify a tuple by replacing the value at a specific index.
 *
 * @param t The original tuple.
 * @param index The index of the value to be replaced.
 * @param value The new value to be inserted.
 * @return The modified tuple.
 * @throws IllegalArgumentException If the index is out of range.
 *
 * Example:
 * modifyTuple(listOf('a', 'b', 'c'), 1, 'x') -> listOf('a', 'x', 'c')
 */
fun modifyTuple(t: List<Any>, index: Int, value: Any): List<Any> {

    try {
        val mutableList = t.toMutableList()
        mutableList[index] = value
        return mutableList
    } catch (e: IndexOutOfBoundsException) {
        throw IllegalArgumentException("Index out of range")
    }
}
/**
 * Modify a tuple by replacing the value at a specific index.
 *
 * @param t The original tuple.
 * @param index The index of the value to be replaced.
 * @param value The new value to be inserted.
 * @return The modified tuple.
 * @throws IllegalArgumentException If the index is out of range.
 *
 * Example:
 * modifyTuple(listOf('a', 'b', 'c'), 1, 'x') -> listOf('a', 'x', 'c')
 */
fun modifyTuple(t: List<Any>, index: Int, value: Any): List<Any> {
/**
 * Modify a tuple by replacing the value at a specific index.
 *
 * @param t The original tuple.
 * @param index The index of the value to be replaced.
 * @param value The new value to be inserted.
 * @return The modified tuple.
 * @throws IllegalArgumentException If the index is out of range.
 *
 * Example:
 * modifyTuple(listOf('a', 'b', 'c'), 1, 'x') -> listOf('a', 'x', 'c')
 */
fun modifyTuple(t: List<Any>, index: Int, value: Any): List<Any> {

    try {
        val mutableList = t.toMutableList()
        mutableList[index] = value
        return mutableList
    } catch (e: IndexOutOfBoundsException) {
        throw IllegalArgumentException("Index out of range")
    }
}