X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=exercises%2Fassignment8-9.mdwn;h=fbdeb850a963047504b60d3a747b9af23343b933;hp=c41ee9baec98b62d115571ae6fc87fa97e104aca;hb=88b8a69e01f705bf5000ce75cd3f70caea1a929d;hpb=94fe70ef2cabab9df44fe56f119db1d9e62bb7f2 diff --git a/exercises/assignment8-9.mdwn b/exercises/assignment8-9.mdwn index c41ee9ba..fbdeb850 100644 --- a/exercises/assignment8-9.mdwn +++ b/exercises/assignment8-9.mdwn @@ -14,20 +14,21 @@ relationships, as in John_x thinks Mary_y said he_x likes her_y. - See her 1999 paper for details. + See her 1999 paper for details. Essentially, she ends up layering several +Reader monads over each other. Here is [[code for the arithmetic tree Chris presented in week 8|code/arith1.ml]]. It computes -`\x. (+ 1 (* (/ 6 x) 4))`. Your task is to modify it to compute -`\x y. (+ 1 (* (/ 6 x) y))`. You will need to modify five lines. +`\n. (+ 1 (* (/ 6 n) 4))`. Your task is to modify it to compute +`\n m. (+ 1 (* (/ 6 n) m))`. You will need to modify five lines. The first one is the type of a boxed int. Instead of `type num = int -> int`, you'll need type num = int -> int -> int The second and third are the definitions of `mid` and `map2`. The fourth -is the one that encodes the variable `x`, the line that begins `(Leaf -(Num (fun x -> ...`. The fifth line you need to modify is the one -that replaces "4" with "y". When you have these lines modified, +is the one that encodes the variable `n`, the line that begins `(Leaf +(Num (fun n -> ...`. The fifth line you need to modify is the one +that replaces "4" with "m". When you have these lines modified, you should be able to execute the following expression: # match eval t2 with Leaf (Num f) -> f 2 4;;