/**
 * This exercise requires implementing a function that finds the intersection between two lists using identity comparison
 * and appends new elements to the first list.
 *
 * @param lst1 The first input list.
 * @param lst2 The second input list.
 * @return The first list after appending new elements from the second list and keeping only the elements that are present in both lists.
 */
fun intersectionAndAppend(lst1: MutableList<Any>, lst2: List<Any>): List<Any> {

    // Find the intersection between lst1 and lst2
    val intersection = lst1.filter { it in lst2 }

    // Append new elements from lst2 to lst1
    for (elem in lst2) {
        if (elem !in lst1) {
            lst1.add(elem)
        }
    }

    return intersection  // Returning the intersection for verification purposes
}
/**
 * This exercise requires implementing a function that finds the intersection between two lists using identity comparison
 * and appends new elements to the first list.
 *
 * @param lst1 The first input list.
 * @param lst2 The second input list.
 * @return The first list after appending new elements from the second list and keeping only the elements that are present in both lists.
 */
fun intersectionAndAppend(lst1: MutableList<Any>, lst2: List<Any>): List<Any> {
/**
 * This exercise requires implementing a function that finds the intersection between two lists using identity comparison
 * and appends new elements to the first list.
 *
 * @param lst1 The first input list.
 * @param lst2 The second input list.
 * @return The first list after appending new elements from the second list and keeping only the elements that are present in both lists.
 */
fun intersectionAndAppend(lst1: MutableList<Any>, lst2: List<Any>): List<Any> {

    // Find the intersection between lst1 and lst2
    val intersection = lst1.filter { it in lst2 }

    // Append new elements from lst2 to lst1
    for (elem in lst2) {
        if (elem !in lst1) {
            lst1.add(elem)
        }
    }

    return intersection  // Returning the intersection for verification purposes
}