Extend the Stats module with the function max_list/1 which returns the maximum number in a list.
max_list([]) should return the atom :undefined.
Hints: * What is the maximum of [e]? (A one element list.) * What is the maximum of [h|t]? * Use the built-in max/2 function to get the maximum of two numbers.
Here is some sample output of how it should work:
iex(1)> xs = [10, 15, 13 , 5, 3, 2, 20, 25, 23] [10, 15, 13, 5, 3, 2, 20, 25, 23] iex(2)> Stats.max_list(xs) 25 iex(3)> Stats.max_list([1,2,3]) 3 iex(4)> Stats.max_list([5,4,3]) 5 iex(5)> ys = for x <- -10..10, do: x*x - 3*x [130, 108, 88, 70, 54, 40, 28, 18, 10, 4, 0, -2, -2, 0, 4, 10, 18, 28, 40, 54, 70] iex(6)> Stats.max_list(ys) 130
Try sampling your Die.roll/0 function a couple of times and see what the maximum is.