/**
 * Given a tuple of elements, replace the elements from the start index to the end index with a new tuple
 * and return the updated tuple.
 *
 * @param elements A tuple of elements.
 * @param startIndex The index to start replacing elements from.
 * @param endIndex The index to end replacing elements at (inclusive).
 * @return The updated tuple after replacing the elements.
 *
 * Example:
 * replaceAndSlice(listOf('a', 'b', 'c', 'd', 'e'), 1, 3) => listOf('a', listOf("new", "tuple"), 'e')
 */
fun replaceAndSlice(elements: List<Any>, startIndex: Int, endIndex: Int): List<Any> {

    val newTuple = listOf("new", "tuple")
    return elements.subList(0, startIndex) + listOf(newTuple) + elements.subList(endIndex + 1, elements.size)
}
/**
 * Given a tuple of elements, replace the elements from the start index to the end index with a new tuple
 * and return the updated tuple.
 *
 * @param elements A tuple of elements.
 * @param startIndex The index to start replacing elements from.
 * @param endIndex The index to end replacing elements at (inclusive).
 * @return The updated tuple after replacing the elements.
 *
 * Example:
 * replaceAndSlice(listOf('a', 'b', 'c', 'd', 'e'), 1, 3) => listOf('a', listOf("new", "tuple"), 'e')
 */
fun replaceAndSlice(elements: List<Any>, startIndex: Int, endIndex: Int): List<Any> {
/**
 * Given a tuple of elements, replace the elements from the start index to the end index with a new tuple
 * and return the updated tuple.
 *
 * @param elements A tuple of elements.
 * @param startIndex The index to start replacing elements from.
 * @param endIndex The index to end replacing elements at (inclusive).
 * @return The updated tuple after replacing the elements.
 *
 * Example:
 * replaceAndSlice(listOf('a', 'b', 'c', 'd', 'e'), 1, 3) => listOf('a', listOf("new", "tuple"), 'e')
 */
fun replaceAndSlice(elements: List<Any>, startIndex: Int, endIndex: Int): List<Any> {

    val newTuple = listOf("new", "tuple")
    return elements.subList(0, startIndex) + listOf(newTuple) + elements.subList(endIndex + 1, elements.size)
}