/**
 * This function takes a list of tuples and an index as input and modifies the elements at the given index in each tuple.
 */
fun modifyTupleElements(tupleList: List<List<Any>>, index: Int): List<List<Any>> {

    return tupleList.map { tuple ->
        try {
            // Convert the tuple to a MutableList to make it mutable
            val tempList = tuple.toMutableList()

            // Modify the element at the given index
            tempList[index] = calculateNewValue(tempList[index])

            // Convert the MutableList back to a List and replace the old tuple in the list
            tempList.toList()
        } catch (e: IndexOutOfBoundsException) {
            tuple
        }
    }
}

fun calculateNewValue(value: Any): Any {
    // Implement your logic to calculate the new value here
    return value // Placeholder implementation
}
/**
 * This function takes a list of tuples and an index as input and modifies the elements at the given index in each tuple.
 */
fun modifyTupleElements(tupleList: List<List<Any>>, index: Int): List<List<Any>> {
/**
 * This function takes a list of tuples and an index as input and modifies the elements at the given index in each tuple.
 */
fun modifyTupleElements(tupleList: List<List<Any>>, index: Int): List<List<Any>> {

    return tupleList.map { tuple ->
        try {
            // Convert the tuple to a MutableList to make it mutable
            val tempList = tuple.toMutableList()

            // Modify the element at the given index
            tempList[index] = calculateNewValue(tempList[index])

            // Convert the MutableList back to a List and replace the old tuple in the list
            tempList.toList()
        } catch (e: IndexOutOfBoundsException) {
            tuple
        }
    }
}

fun calculateNewValue(value: Any): Any {
    // Implement your logic to calculate the new value here
    return value // Placeholder implementation
}