Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


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?