(* * Returns a list of ints from 0 to n * with one small downside *) let rec listOfInts n = match n with | 0 -> [0] | i -> i :: listOfInts (i - 1) (* * Here's a version that does what we * want but without the downside. It * Uses a local declaration to hide * a helper function. *) let listOfInts2 n = let rec li n = match n with | 0 -> [0] | i -> i :: listOfInts (i - 1) li n |> List.rev (* * Zach asked after class if we can just * compose functions in ML like we can * in mathematics. Indeed we can! * Here is a function equivalent to * listOfInts2 written in what is called * "points free style" ("points" is * type theory speak for "parameters"). * See if you can figure out why this * works. >> means "compose". *) let listOfInts3 = listOfInts >> List.rev (* * Here is the first function again, but this * time with type annotations. *) let rec listOfInts4 (n: int) : int list = match n with | 0 -> [0] | i -> i :: listOfInts (i - 1) (* Call one of these functions like *) listOfInts2 5