/**
 * This function performs the specified action on two marketing lists using sets.
 *
 * @param marketingList1 The first marketing list.
 * @param marketingList2 The second marketing list.
 * @param action The action to be performed on the lists. 'intersection' to find the common elements,
 *               'append' to combine the lists, or 'remove' to remove common elements.
 * @return The result of the specified action on the marketing lists.
 * @throws IllegalArgumentException If the action parameter is not 'intersection', 'append', or 'remove'.
 */
fun setOperation(marketingList1: Set<String>, marketingList2: Set<String>, action: String): Set<String> {

    return when (action) {
        "intersection" -> marketingList1.intersect(marketingList2)
        "append" -> marketingList1.union(marketingList2)
        "remove" -> marketingList1.subtract(marketingList2)
        else -> throw IllegalArgumentException("Invalid action! Please choose either 'intersection', 'append', or 'remove'.")
    }
}

// Example usage:
val list1 = setOf("John", "Amy", "Tom", "Sara")
/**
 * This function performs the specified action on two marketing lists using sets.
 *
 * @param marketingList1 The first marketing list.
 * @param marketingList2 The second marketing list.
 * @param action The action to be performed on the lists. 'intersection' to find the common elements,
 *               'append' to combine the lists, or 'remove' to remove common elements.
 * @return The result of the specified action on the marketing lists.
 * @throws IllegalArgumentException If the action parameter is not 'intersection', 'append', or 'remove'.
 */
fun setOperation(marketingList1: Set<String>, marketingList2: Set<String>, action: String): Set<String> {
/**
 * This function performs the specified action on two marketing lists using sets.
 *
 * @param marketingList1 The first marketing list.
 * @param marketingList2 The second marketing list.
 * @param action The action to be performed on the lists. 'intersection' to find the common elements,
 *               'append' to combine the lists, or 'remove' to remove common elements.
 * @return The result of the specified action on the marketing lists.
 * @throws IllegalArgumentException If the action parameter is not 'intersection', 'append', or 'remove'.
 */
fun setOperation(marketingList1: Set<String>, marketingList2: Set<String>, action: String): Set<String> {

    return when (action) {
        "intersection" -> marketingList1.intersect(marketingList2)
        "append" -> marketingList1.union(marketingList2)
        "remove" -> marketingList1.subtract(marketingList2)
        else -> throw IllegalArgumentException("Invalid action! Please choose either 'intersection', 'append', or 'remove'.")
    }
}

// Example usage:
val list1 = setOf("John", "Amy", "Tom", "Sara")