/**
 * This exercise requires modifying a given list based on a condition using nested ternary operators.
 *
 * @param data_list The list to be modified.
 * @param condition The condition to be checked.
 * @return The modified list.
 *
 * Example:
 * modifyListWithNestedTernaryOperators(listOf(1, 2, 3, 4, 5), true) // [1, -2, 3, -4, 5]
 */
fun modifyListWithNestedTernaryOperators(dataList: MutableList<Int>, condition: Boolean): List<Int> {

    // Iterate through each element in the list, modifying it based on the condition
    for (i in dataList.indices) {
        // If the condition is true, multiply the element by -1, otherwise, divide it by 2
        dataList[i] = if (condition) dataList[i] * -1 else dataList[i] / 2
    }
    return dataList
}
/**
 * This exercise requires modifying a given list based on a condition using nested ternary operators.
 *
 * @param data_list The list to be modified.
 * @param condition The condition to be checked.
 * @return The modified list.
 *
 * Example:
 * modifyListWithNestedTernaryOperators(listOf(1, 2, 3, 4, 5), true) // [1, -2, 3, -4, 5]
 */
fun modifyListWithNestedTernaryOperators(dataList: MutableList<Int>, condition: Boolean): List<Int> {
/**
 * This exercise requires modifying a given list based on a condition using nested ternary operators.
 *
 * @param data_list The list to be modified.
 * @param condition The condition to be checked.
 * @return The modified list.
 *
 * Example:
 * modifyListWithNestedTernaryOperators(listOf(1, 2, 3, 4, 5), true) // [1, -2, 3, -4, 5]
 */
fun modifyListWithNestedTernaryOperators(dataList: MutableList<Int>, condition: Boolean): List<Int> {

    // Iterate through each element in the list, modifying it based on the condition
    for (i in dataList.indices) {
        // If the condition is true, multiply the element by -1, otherwise, divide it by 2
        dataList[i] = if (condition) dataList[i] * -1 else dataList[i] / 2
    }
    return dataList
}