X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=exercises%2Fassignment5.mdwn;h=73889482c1999d37564b214af2e9419da50d9d7f;hp=f4955d9db34f525c0178c3e320769bee5d9a474e;hb=fd809f4237e5720a985e116e472ebd045c55baa9;hpb=d7b2ba7d870cccd91313e5d32a6c195ee5140dcd diff --git a/exercises/assignment5.mdwn b/exercises/assignment5.mdwn index f4955d9d..73889482 100644 --- a/exercises/assignment5.mdwn +++ b/exercises/assignment5.mdwn @@ -116,7 +116,7 @@ Choose one of these languages and write the following functions. 6. How would you use the function defined in problem 4 to enumerate a tree's fringe? (Don't worry about whether it comes out left-to-right or right-to-left.) -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 hint4]], if you need one.) +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.) 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: @@ -329,9 +329,7 @@ any type `α`, as long as your function is of type `α -> α` and you have a bas -- Or this: let sysf_true = (\y n -> y) :: Sysf_bool a - Note that in both OCaml and the Haskell code, the generalization `∀'a` on the free type variable `'a` is implicit. If you really want to, you can supply it explicitly in Haskell by saying: - - :set -XExplicitForAll + :set -XExplicitForAll let { sysf_true :: forall a. Sysf_bool a; ... } -- or let { sysf_true :: forall a. a -> a -> a; ... } @@ -408,7 +406,7 @@ Be sure to test your proposals with simple lists. (You'll have to `sysf_cons` up # k 1 true ;; - : int = 1 - If you can't understand how one term can have several types, recall our discussion in this week's notes of "principal types". (WHERE?) + If you can't understand how one term can have several types, recall our discussion in this week's notes of "principal types".