/**
 * Given a list of elements, append a new element only if it is less than the specified value.
 *
 * @param elementsList A list of elements.
 * @param value The threshold value.
 * @return Updated list of elements where the new element is appended if it is less than the threshold value.
 */
fun appendLessThan(elementsList: MutableList<Double>, value: Double): List<Double> {

    // Find the index where the new element should be inserted
    var index = 0
    while (index < elementsList.size && elementsList[index] < value) {
        index++
    }

    // Ask the user for the new element
    print("Enter the new element: ")
    val newElement = readLine()!!.toDouble()

    // Check if the new element satisfies the condition
    if (newElement < value) {
        // Insert the new element at the correct position
        elementsList.add(index, newElement)
    }

    return elementsList
}
/**
 * Given a list of elements, append a new element only if it is less than the specified value.
 *
 * @param elementsList A list of elements.
 * @param value The threshold value.
 * @return Updated list of elements where the new element is appended if it is less than the threshold value.
 */
fun appendLessThan(elementsList: MutableList<Double>, value: Double): List<Double> {
/**
 * Given a list of elements, append a new element only if it is less than the specified value.
 *
 * @param elementsList A list of elements.
 * @param value The threshold value.
 * @return Updated list of elements where the new element is appended if it is less than the threshold value.
 */
fun appendLessThan(elementsList: MutableList<Double>, value: Double): List<Double> {

    // Find the index where the new element should be inserted
    var index = 0
    while (index < elementsList.size && elementsList[index] < value) {
        index++
    }

    // Ask the user for the new element
    print("Enter the new element: ")
    val newElement = readLine()!!.toDouble()

    // Check if the new element satisfies the condition
    if (newElement < value) {
        // Insert the new element at the correct position
        elementsList.add(index, newElement)
    }

    return elementsList
}