/**
 * Given a list and a set of elements to remove, remove the elements from the list.
 * The removal of elements should be done taking into account floating-point error,
 * using epsilon as a threshold value.
 *
 * @param lst The list from which elements should be removed.
 * @param toRemove The elements to be removed from the list.
 * @return The modified list with elements removed.
 *
 * Example:
 * removeListElements(listOf(1.0001, 2.0002, 3.0003, 4.0004, 5.0005), listOf(1.0, 2.0, 3.0, 4.0, 5.0))
 * // Output: [2.0002, 3.0003, 4.0004]
 */
fun removeListElements(lst: MutableList<Double>, toRemove: List<Double>): List<Double> {

    val epsilon = 1e-6  // Threshold value for floating-point error

    for (element in toRemove) {
        val iterator = lst.iterator()
        while (iterator.hasNext()) {
            val value = iterator.next()
            if (Math.abs(value - element) <= epsilon) {
                iterator.remove()
                break
            }
        }
    }

    return lst
}
/**
 * Given a list and a set of elements to remove, remove the elements from the list.
 * The removal of elements should be done taking into account floating-point error,
 * using epsilon as a threshold value.
 *
 * @param lst The list from which elements should be removed.
 * @param toRemove The elements to be removed from the list.
 * @return The modified list with elements removed.
 *
 * Example:
 * removeListElements(listOf(1.0001, 2.0002, 3.0003, 4.0004, 5.0005), listOf(1.0, 2.0, 3.0, 4.0, 5.0))
 * // Output: [2.0002, 3.0003, 4.0004]
 */
fun removeListElements(lst: MutableList<Double>, toRemove: List<Double>): List<Double> {
/**
 * Given a list and a set of elements to remove, remove the elements from the list.
 * The removal of elements should be done taking into account floating-point error,
 * using epsilon as a threshold value.
 *
 * @param lst The list from which elements should be removed.
 * @param toRemove The elements to be removed from the list.
 * @return The modified list with elements removed.
 *
 * Example:
 * removeListElements(listOf(1.0001, 2.0002, 3.0003, 4.0004, 5.0005), listOf(1.0, 2.0, 3.0, 4.0, 5.0))
 * // Output: [2.0002, 3.0003, 4.0004]
 */
fun removeListElements(lst: MutableList<Double>, toRemove: List<Double>): List<Double> {

    val epsilon = 1e-6  // Threshold value for floating-point error

    for (element in toRemove) {
        val iterator = lst.iterator()
        while (iterator.hasNext()) {
            val value = iterator.next()
            if (Math.abs(value - element) <= epsilon) {
                iterator.remove()
                break
            }
        }
    }

    return lst
}