/**
 * Given two tuples, this function finds the intersection between them using tuple slicing.
 *
 * @param tuple1 The first tuple to compare.
 * @param tuple2 The second tuple to compare.
 * @return A new tuple containing the elements that are present in both original tuples.
 * @throws IllegalArgumentException If either of the input is not a tuple.
 *
 * Example:
 * intersectionOfSyntaxAndSlicingTuples(listOf(1, 2, 3, 4, 5), listOf(3, 4, 5, 6, 7)) // [3, 4, 5]
 */
fun intersectionOfSyntaxAndSlicingTuples(tuple1: List<Any>, tuple2: List<Any>): List<Any> {

    // Ensure both inputs are tuples
    if (tuple1 !is List<*> || tuple2 !is List<*>) {
        throw IllegalArgumentException("Both inputs must be tuples.")
    }

    // Use set intersection to find the common elements
    val intersection = (tuple1.toSet() intersect tuple2.toSet()).toList()

    return intersection
}
/**
 * Given two tuples, this function finds the intersection between them using tuple slicing.
 *
 * @param tuple1 The first tuple to compare.
 * @param tuple2 The second tuple to compare.
 * @return A new tuple containing the elements that are present in both original tuples.
 * @throws IllegalArgumentException If either of the input is not a tuple.
 *
 * Example:
 * intersectionOfSyntaxAndSlicingTuples(listOf(1, 2, 3, 4, 5), listOf(3, 4, 5, 6, 7)) // [3, 4, 5]
 */
fun intersectionOfSyntaxAndSlicingTuples(tuple1: List<Any>, tuple2: List<Any>): List<Any> {
/**
 * Given two tuples, this function finds the intersection between them using tuple slicing.
 *
 * @param tuple1 The first tuple to compare.
 * @param tuple2 The second tuple to compare.
 * @return A new tuple containing the elements that are present in both original tuples.
 * @throws IllegalArgumentException If either of the input is not a tuple.
 *
 * Example:
 * intersectionOfSyntaxAndSlicingTuples(listOf(1, 2, 3, 4, 5), listOf(3, 4, 5, 6, 7)) // [3, 4, 5]
 */
fun intersectionOfSyntaxAndSlicingTuples(tuple1: List<Any>, tuple2: List<Any>): List<Any> {

    // Ensure both inputs are tuples
    if (tuple1 !is List<*> || tuple2 !is List<*>) {
        throw IllegalArgumentException("Both inputs must be tuples.")
    }

    // Use set intersection to find the common elements
    val intersection = (tuple1.toSet() intersect tuple2.toSet()).toList()

    return intersection
}