We want to define a function randList(len : Int, n : Int) : List[Int] that makes a list of length len of random integers between 0 and n - 1. For example, randList(5, 10) might yield a list of numbers 5 1 2 0 9. Define randList as a recursive function. What is the code of your function?

Hint: If len is 0, the result is nil. Otherwise, it is gen.nextInt(n) :: something. What is your definition?

Note: You need not define gen. You already defined it in part 1. Just use it.
What do you get for randList(5, 1000)? For randList(1000, 5)?
Why is randList a closure?