Check the range constructor method in LazyList and complete the following function, ensuring that the arguments are valid. The function must return a list of all numbers from start to end. The list should not be calculated immediately.
Lazy evaluations
Imagine the range of numbers, we don't calculate them
Report a typo
Sample Input 1:
2
5Sample Output 1:
2
3
4Write a program in Scala 3
def safeRange(start: Int, end: Int): LazyList[Int] =
if (start >= end) LazyList.empty
else LazyList.???
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.