/**
 * This function removes elements from a list if they are smaller than the specified threshold and rounds the remaining elements to a specific precision.
 *
 * @param data A list of floating-point numbers.
 * @param threshold A float value representing the minimum value for an element to be kept in the list.
 * @return A new list of rounded floating-point numbers, excluding those that were smaller than the threshold.
 */
fun removeAndRound(data: List<Double>, threshold: Double): List<Double> {

    val newData = mutableListOf<Double>()
    for (number in data) {
        if (number >= threshold) {
            newData.add(number.round(2))  // Rounds each element to a precision of 2 decimal places
        }
    }
    return newData
}

fun Double.round(decimals: Int): Double = "%.${decimals}f".format(this).toDouble()
/**
 * This function removes elements from a list if they are smaller than the specified threshold and rounds the remaining elements to a specific precision.
 *
 * @param data A list of floating-point numbers.
 * @param threshold A float value representing the minimum value for an element to be kept in the list.
 * @return A new list of rounded floating-point numbers, excluding those that were smaller than the threshold.
 */
fun removeAndRound(data: List<Double>, threshold: Double): List<Double> {
/**
 * This function removes elements from a list if they are smaller than the specified threshold and rounds the remaining elements to a specific precision.
 *
 * @param data A list of floating-point numbers.
 * @param threshold A float value representing the minimum value for an element to be kept in the list.
 * @return A new list of rounded floating-point numbers, excluding those that were smaller than the threshold.
 */
fun removeAndRound(data: List<Double>, threshold: Double): List<Double> {

    val newData = mutableListOf<Double>()
    for (number in data) {
        if (number >= threshold) {
            newData.add(number.round(2))  // Rounds each element to a precision of 2 decimal places
        }
    }
    return newData
}

fun Double.round(decimals: Int): Double = "%.${decimals}f".format(this).toDouble()