7. Write a recursive function to make a copy of a `color_tree` with the same structure and inner branch colors, but where the leftmost leaf is now labeled `0`, the second-leftmost leaf is now labeled `1`, and so on. (Here's a [[hint|assignment5 hint3]], if you need one.)
+Hint: Consider this pattern:
+
+ # let rec enumerate_from (t:'a color_tree) counter = match t with
+ | Leaf x -> (Leaf counter, counter+1)
+ | Branch (left,col,right) -> let (left',counter') = ... in
+ let (right',counter'') = ... in
+ ...
+ ;;
+
+
8. (More challenging.) Write a recursive function that makes a copy of a `color_tree` with the same structure and inner branch colors, but replaces each leaf label with the `int` that reports how many of that leaf's ancestors are labeled `Red`. For example, if we give your function a tree:
<pre>
does not terminate. Incidentally, using the shorter `match bool with true -> yes | false -> no` rather than the longer `let b = bool ... in match b with ...` *would* work as we desire. But your assignment is to control the evaluation order *without* using the special evaluation order properties of OCaml's native `if` or of its `match`. That is, you must keep the `let b = ... in match b with ...` structure in your answer, though you are allowed to adjust what `b`, `y`, and `n` get assigned to.
Here's a [[hint|assignment5 hint1]].
+
+Hint: Use thunks!
+
+Further hint: What does
+
+ let x = (fun () -> 2) in
+ let y = (fun () -> 3) in
+ match true with true -> x | false -> y
+
+evaluate to?