/**
 * Given a list of floating-point elements and an epsilon value,
 * the function checks if any element in the list is close to zero
 * within the given epsilon. If an element is close to zero, it is
 * set to exactly zero.
 *
 * @param elements A list of floating-point numbers.
 * @param epsilon The tolerance value to determine closeness to zero.
 * @return The modified list with elements close to zero set to zero.
 */
fun modifyListElements(elements: MutableList<Double>, epsilon: Double): List<Double> {

    for (i in elements.indices) {
        if (Math.abs(elements[i]) < epsilon) {
            elements[i] = 0.0
        }
    }
    return elements
}

// Modify the elements and set those close to zero to exactly zero
/**
 * Given a list of floating-point elements and an epsilon value,
 * the function checks if any element in the list is close to zero
 * within the given epsilon. If an element is close to zero, it is
 * set to exactly zero.
 *
 * @param elements A list of floating-point numbers.
 * @param epsilon The tolerance value to determine closeness to zero.
 * @return The modified list with elements close to zero set to zero.
 */
fun modifyListElements(elements: MutableList<Double>, epsilon: Double): List<Double> {
/**
 * Given a list of floating-point elements and an epsilon value,
 * the function checks if any element in the list is close to zero
 * within the given epsilon. If an element is close to zero, it is
 * set to exactly zero.
 *
 * @param elements A list of floating-point numbers.
 * @param epsilon The tolerance value to determine closeness to zero.
 * @return The modified list with elements close to zero set to zero.
 */
fun modifyListElements(elements: MutableList<Double>, epsilon: Double): List<Double> {

    for (i in elements.indices) {
        if (Math.abs(elements[i]) < epsilon) {
            elements[i] = 0.0
        }
    }
    return elements
}

// Modify the elements and set those close to zero to exactly zero