From 57dee2bbf8450a3ee982f8bdc868a6258b38da0e Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 14 Mar 2015 15:13:55 -0400 Subject: [PATCH] exx --- exercises/_assignment6.mdwn | 18 ------------------ exercises/_assignment7.mdwn | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 exercises/_assignment7.mdwn diff --git a/exercises/_assignment6.mdwn b/exercises/_assignment6.mdwn index 86c398ff..9a3d04c0 100644 --- a/exercises/_assignment6.mdwn +++ b/exercises/_assignment6.mdwn @@ -112,21 +112,3 @@ our scorecard. On the simple-minded view, we would replace it with `w`. But that's not the right result, because `w` itself has been mapped onto 2. -## Baby monads - -(Depends on lecture notes for safe division by zero.) - -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`. -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' (u: int option) (f: int -> (int option)) = - match u with None -> None | Some x -> f x;; diff --git a/exercises/_assignment7.mdwn b/exercises/_assignment7.mdwn new file mode 100644 index 00000000..793a15e4 --- /dev/null +++ b/exercises/_assignment7.mdwn @@ -0,0 +1,18 @@ +## Baby monads + +(Depends on lecture notes for safe division by zero.) + +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`. +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' (u: int option) (f: int -> (int option)) = + match u with None -> None | Some x -> f x;; -- 2.11.0