/**
 * Given a list of elements and a range of indices, this function removes the specified range of elements from the original list and returns the remaining elements.
 */
fun subtractElements(elements: MutableList<Any>, indexRange: IntRange): List<Any> {

    val result = elements.toMutableList()  // creating a copy of the original list

    // removing the specified range of elements
    result.subList(indexRange.first, indexRange.last + 1).clear()

    return result
}
/**
 * Given a list of elements and a range of indices, this function removes the specified range of elements from the original list and returns the remaining elements.
 */
fun subtractElements(elements: MutableList<Any>, indexRange: IntRange): List<Any> {
/**
 * Given a list of elements and a range of indices, this function removes the specified range of elements from the original list and returns the remaining elements.
 */
fun subtractElements(elements: MutableList<Any>, indexRange: IntRange): List<Any> {

    val result = elements.toMutableList()  // creating a copy of the original list

    // removing the specified range of elements
    result.subList(indexRange.first, indexRange.last + 1).clear()

    return result
}