/**
 * This exercise focuses on the advantages and introduction to the range function.
 * Your task is to implement a function that takes in three arguments: start, stop, and step.
 * The function should return a list containing all the numbers in the given range, with the specified step.
 *
 * @param start The starting value of the range (inclusive).
 * @param stop The ending value of the range (exclusive).
 * @param step The increment value between each number.
 * @return A list containing all the numbers in the range.
 *
 * Advantages of range function:
 * - Memory efficient: The range function generates numbers on the fly rather than storing them all in memory.
 * - Iterative structure: Range is often used in loops to iterate a specific number of times.
 */
fun rangeIntroAdvantages(start: Int, stop: Int, step: Int): List<Int> {

    val result = mutableListOf<Int>()
    var current = start

    if (step > 0) {
        while (current < stop) {
            result.add(current)
            current += step
        }
    } else {
        while (current > stop) {
            result.add(current)
            current += step
        }
    }

    return result
}
/**
 * This exercise focuses on the advantages and introduction to the range function.
 * Your task is to implement a function that takes in three arguments: start, stop, and step.
 * The function should return a list containing all the numbers in the given range, with the specified step.
 *
 * @param start The starting value of the range (inclusive).
 * @param stop The ending value of the range (exclusive).
 * @param step The increment value between each number.
 * @return A list containing all the numbers in the range.
 *
 * Advantages of range function:
 * - Memory efficient: The range function generates numbers on the fly rather than storing them all in memory.
 * - Iterative structure: Range is often used in loops to iterate a specific number of times.
 */
fun rangeIntroAdvantages(start: Int, stop: Int, step: Int): List<Int> {
/**
 * This exercise focuses on the advantages and introduction to the range function.
 * Your task is to implement a function that takes in three arguments: start, stop, and step.
 * The function should return a list containing all the numbers in the given range, with the specified step.
 *
 * @param start The starting value of the range (inclusive).
 * @param stop The ending value of the range (exclusive).
 * @param step The increment value between each number.
 * @return A list containing all the numbers in the range.
 *
 * Advantages of range function:
 * - Memory efficient: The range function generates numbers on the fly rather than storing them all in memory.
 * - Iterative structure: Range is often used in loops to iterate a specific number of times.
 */
fun rangeIntroAdvantages(start: Int, stop: Int, step: Int): List<Int> {

    val result = mutableListOf<Int>()
    var current = start

    if (step > 0) {
        while (current < stop) {
            result.add(current)
            current += step
        }
    } else {
        while (current > stop) {
            result.add(current)
            current += step
        }
    }

    return result
}