/**
 * This function takes a set, list, and a list of elements as input.
 * It adds the elements to the set and appends them to the list, maintaining the order of the list.
 *
 * @param inputSet The set to which elements need to be added.
 * @param inputList The list to which elements need to be appended.
 * @param elements The list of elements to be added and appended.
 * @return The updated list after adding elements and appending them.
 */
fun addToSetAndAppend(inputSet: MutableSet<Any>, inputList: MutableList<Any>, elements: List<Any>): List<Any> {

    for (element in elements) {
        if (element !in inputSet) { // Ensures only unique elements are added to the set
            inputSet.add(element)
            inputList.add(element)
        }
    }
    return inputList
}
/**
 * This function takes a set, list, and a list of elements as input.
 * It adds the elements to the set and appends them to the list, maintaining the order of the list.
 *
 * @param inputSet The set to which elements need to be added.
 * @param inputList The list to which elements need to be appended.
 * @param elements The list of elements to be added and appended.
 * @return The updated list after adding elements and appending them.
 */
fun addToSetAndAppend(inputSet: MutableSet<Any>, inputList: MutableList<Any>, elements: List<Any>): List<Any> {
/**
 * This function takes a set, list, and a list of elements as input.
 * It adds the elements to the set and appends them to the list, maintaining the order of the list.
 *
 * @param inputSet The set to which elements need to be added.
 * @param inputList The list to which elements need to be appended.
 * @param elements The list of elements to be added and appended.
 * @return The updated list after adding elements and appending them.
 */
fun addToSetAndAppend(inputSet: MutableSet<Any>, inputList: MutableList<Any>, elements: List<Any>): List<Any> {

    for (element in elements) {
        if (element !in inputSet) { // Ensures only unique elements are added to the set
            inputSet.add(element)
            inputList.add(element)
        }
    }
    return inputList
}