/**
 * Concatenates all the numbers in the given range into a single string, separated by a space.
 *
 * @param start The starting value of the range.
 * @param stop The end value of the range (exclusive).
 * @param step The difference between each consecutive value in the range.
 * @return The string representation of the range.
 * @throws IllegalArgumentException If step is zero or the range does not contain any numbers.
 */
fun rangeToStr(start: Double, stop: Double, step: Double): String {

    if (step == 0.0) {
        throw IllegalArgumentException("Step cannot be zero.")
    }

    if ((start < stop && step < 0) || (start > stop && step > 0)) {
        throw IllegalArgumentException("Invalid range, step should be positive if start < stop and negative if start > stop.")
    }

    var result = ""
    var current = start
    while ((step > 0 && current < stop) || (step < 0 && current > stop)) {
        result += "$current "
        current += step
    }

    if (result.isEmpty()) {
        throw IllegalArgumentException("No numbers in the given range.")
    }

    return result.trim()
}
/**
 * Concatenates all the numbers in the given range into a single string, separated by a space.
 *
 * @param start The starting value of the range.
 * @param stop The end value of the range (exclusive).
 * @param step The difference between each consecutive value in the range.
 * @return The string representation of the range.
 * @throws IllegalArgumentException If step is zero or the range does not contain any numbers.
 */
fun rangeToStr(start: Double, stop: Double, step: Double): String {
/**
 * Concatenates all the numbers in the given range into a single string, separated by a space.
 *
 * @param start The starting value of the range.
 * @param stop The end value of the range (exclusive).
 * @param step The difference between each consecutive value in the range.
 * @return The string representation of the range.
 * @throws IllegalArgumentException If step is zero or the range does not contain any numbers.
 */
fun rangeToStr(start: Double, stop: Double, step: Double): String {

    if (step == 0.0) {
        throw IllegalArgumentException("Step cannot be zero.")
    }

    if ((start < stop && step < 0) || (start > stop && step > 0)) {
        throw IllegalArgumentException("Invalid range, step should be positive if start < stop and negative if start > stop.")
    }

    var result = ""
    var current = start
    while ((step > 0 && current < stop) || (step < 0 && current > stop)) {
        result += "$current "
        current += step
    }

    if (result.isEmpty()) {
        throw IllegalArgumentException("No numbers in the given range.")
    }

    return result.trim()
}