X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=assignment5.mdwn;h=f402ec61a70bbe9ebe4e5f7c2f4a2f1ecc853ede;hp=fee1d8334575bbdefdd4f8572b2aafc3f62e6531;hb=3ed8e56bf33b1c0cfa09b672abf26e9c397ea0f1;hpb=74c28ae2bdc6692628a47f6bb383d0777256b930;ds=sidebyside
diff --git a/assignment5.mdwn b/assignment5.mdwn
index fee1d833..f402ec61 100644
--- a/assignment5.mdwn
+++ b/assignment5.mdwn
@@ -121,7 +121,7 @@ and that "bool" is any boolean. Then we can try the following:
or of `match`. That is, you must keep the `let` statements, though
you're allowed to adjust what `b`, `y`, and `n` get assigned to.
- [[Hint assignment 5 problem 3]]
+ [[hints/assignment 5 hint 1]]
Booleans, Church numerals, and v3 lists in OCaml
------------------------------------------------
@@ -210,7 +210,7 @@ value to give back if the argument is the empty list. Ultimately, we might
want to make use of our `'a option` technique, but for this assignment, just
pick a strategy, no matter how clunky.
-Be sure to test your proposals with simple lists. (You'll have to make_list
+Be sure to test your proposals with simple lists. (You'll have to `make_list`
the lists yourself; don't expect OCaml to magically translate between its
native lists and the ones you buil.d)
@@ -233,20 +233,20 @@ any auxiliary functions you need.
Baby monads
-----------
-Read the lecture notes for week 6, then write a
-function `lift'` that generalized the correspondence between + and
-`add'`: that is, `lift'` takes any two-place operation on integers
-and returns a version that takes arguments of type `int option`
-instead, returning a result of `int option`. In other words,
-`lift'` will have type
+Read the material on dividing by zero/towards monads from ~~the end of lecture
+notes for week 6~~ the start of lecture notes for week 7, then write a function `lift'` that generalized the
+correspondence between + and `add'`: that is, `lift'` takes any two-place
+operation on integers and returns a version that takes arguments of type `int
+option` instead, returning a result of `int option`. In other words, `lift'`
+will have type:
(int -> int -> int) -> (int option) -> (int option) -> (int option)
-so that `lift' (+) (Some 3) (Some 4)` will evalute to `Some 7`.
+so that `lift' (+) (Some 3) (Some 4)` will evalute to `Some 7`.
Don't worry about why you need to put `+` inside of parentheses.
You should make use of `bind'` in your definition of `lift'`:
- let bind' (x: int option) (f: int -> (int option)) =
- match x with None -> None | Some n -> f n;;
+ let bind' (u: int option) (f: int -> (int option)) =
+ match u with None -> None | Some x -> f x;;