/**
 * Check for intersection of elements using both identity comparison and membership operators.
 *
 * @param lst1 A list of objects.
 * @param lst2 Another list of objects.
 * @return A list of elements that are common in both input lists.
 */
fun checkMembershipAndComparison(lst1: List<Any>, lst2: List<Any>): List<Any> {

    // Create an empty list to store the common elements
    val commonElements = mutableListOf<Any>()

    // Iterate through each element in the first list
    for (elem1 in lst1) {
        // Iterate through each element in the second list
        for (elem2 in lst2) {
            // Check if the element references are the same (identity comparison)
            if (elem1 === elem2) {
                // Check if the element is not already in the common elements list
                if (elem1 !in commonElements) {
                    // Add the element to common elements
                    commonElements.add(elem1)
                }
            }
        }
    }

    // Return the list of common elements
    return commonElements
}
/**
 * Check for intersection of elements using both identity comparison and membership operators.
 *
 * @param lst1 A list of objects.
 * @param lst2 Another list of objects.
 * @return A list of elements that are common in both input lists.
 */
fun checkMembershipAndComparison(lst1: List<Any>, lst2: List<Any>): List<Any> {
/**
 * Check for intersection of elements using both identity comparison and membership operators.
 *
 * @param lst1 A list of objects.
 * @param lst2 Another list of objects.
 * @return A list of elements that are common in both input lists.
 */
fun checkMembershipAndComparison(lst1: List<Any>, lst2: List<Any>): List<Any> {

    // Create an empty list to store the common elements
    val commonElements = mutableListOf<Any>()

    // Iterate through each element in the first list
    for (elem1 in lst1) {
        // Iterate through each element in the second list
        for (elem2 in lst2) {
            // Check if the element references are the same (identity comparison)
            if (elem1 === elem2) {
                // Check if the element is not already in the common elements list
                if (elem1 !in commonElements) {
                    // Add the element to common elements
                    commonElements.add(elem1)
                }
            }
        }
    }

    // Return the list of common elements
    return commonElements
}