/**
 * Given a list [lst], replace all occurrences of [element] with [newElement].
 * If [newElement] is an empty string, remove all occurrences of [element] from [lst].
 *
 * @param lst The list to be modified.
 * @param element The element to be replaced or removed.
 * @param newElement The element to replace [element] or an empty string to remove [element].
 * @return The modified list.
 */
fun replaceElements(lst: List<String>, element: String, newElement: String): List<String> {

    return when {
        lst.isNotEmpty() && element.isNotEmpty() && newElement.isNotEmpty() -> lst.map { if (it == element) newElement else it }
        lst.isNotEmpty() && element.isNotEmpty() && newElement.isEmpty() -> lst.filter { it != element }
        else -> lst
    }
}
/**
 * Given a list [lst], replace all occurrences of [element] with [newElement].
 * If [newElement] is an empty string, remove all occurrences of [element] from [lst].
 *
 * @param lst The list to be modified.
 * @param element The element to be replaced or removed.
 * @param newElement The element to replace [element] or an empty string to remove [element].
 * @return The modified list.
 */
fun replaceElements(lst: List<String>, element: String, newElement: String): List<String> {
/**
 * Given a list [lst], replace all occurrences of [element] with [newElement].
 * If [newElement] is an empty string, remove all occurrences of [element] from [lst].
 *
 * @param lst The list to be modified.
 * @param element The element to be replaced or removed.
 * @param newElement The element to replace [element] or an empty string to remove [element].
 * @return The modified list.
 */
fun replaceElements(lst: List<String>, element: String, newElement: String): List<String> {

    return when {
        lst.isNotEmpty() && element.isNotEmpty() && newElement.isNotEmpty() -> lst.map { if (it == element) newElement else it }
        lst.isNotEmpty() && element.isNotEmpty() && newElement.isEmpty() -> lst.filter { it != element }
        else -> lst
    }
}