/**
 * Given a list of tuples and a set, return a new set containing the intersection
 * of each tuple with the given set. The intersection of a tuple with a set is the
 * set of elements that are common to both the tuple and the set.
 *
 * @param tuples A list of tuples, each comprising elements of any data type.
 * @param sets A set containing elements of any data type.
 * @return A new set containing the intersection of each tuple with the given set.
 */
fun intersectionOfTuplesAndSets(tuples: List<Set<Any>>, sets: Set<Any>): Set<Any> {

    val intersection = mutableSetOf<Any>()

    for (tup in tuples) {
        intersection.addAll(tup.intersect(sets))
    }

    return intersection
}

// Example usage
/**
 * Given a list of tuples and a set, return a new set containing the intersection
 * of each tuple with the given set. The intersection of a tuple with a set is the
 * set of elements that are common to both the tuple and the set.
 *
 * @param tuples A list of tuples, each comprising elements of any data type.
 * @param sets A set containing elements of any data type.
 * @return A new set containing the intersection of each tuple with the given set.
 */
fun intersectionOfTuplesAndSets(tuples: List<Set<Any>>, sets: Set<Any>): Set<Any> {
/**
 * Given a list of tuples and a set, return a new set containing the intersection
 * of each tuple with the given set. The intersection of a tuple with a set is the
 * set of elements that are common to both the tuple and the set.
 *
 * @param tuples A list of tuples, each comprising elements of any data type.
 * @param sets A set containing elements of any data type.
 * @return A new set containing the intersection of each tuple with the given set.
 */
fun intersectionOfTuplesAndSets(tuples: List<Set<Any>>, sets: Set<Any>): Set<Any> {

    val intersection = mutableSetOf<Any>()

    for (tup in tuples) {
        intersection.addAll(tup.intersect(sets))
    }

    return intersection
}

// Example usage