From: Jim Pryor Date: Thu, 16 Dec 2010 14:01:44 +0000 (-0500) Subject: assignment 10 tweaks X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=commitdiff_plain;h=6097d678d4529d775014d378a5d42f7739be8db4 assignment 10 tweaks Signed-off-by: Jim Pryor --- diff --git a/assignment10.mdwn b/assignment10.mdwn index 97d20982..a2e5d42f 100644 --- a/assignment10.mdwn +++ b/assignment10.mdwn @@ -12,7 +12,7 @@ Here is [a hint](/hints/assignment_10_hint). -2. Armed with your solution to problem 1, try this: you have as input a lead-labeled, binary tree whose labels are strings. You also have as input an interpretation function from strings to meanings. Let the meanings of your strings be primitive elements, for instance: +2. Armed with your solution to problem 1, try this: you have as input a leaf-labeled, binary tree whose labels are strings. You also have as input an interpretation function from strings to meanings. Let the meanings of your strings be primitive elements, for instance: type meaning = John | Bill | Sally | Zachariah | Swam | Likes | ... @@ -39,7 +39,7 @@ That won't compile in OCaml because we use the `M`s in a way that's intuitive but unrecognized by OCaml. What OCaml will recognize is more complex. Don't worry; you won't need to code a general implementation of StateT. - What we do want you to do is to implement StateT(List). That is, plug in the implementations of the List monad's type, unit, and bind into the preceding definitions. That will be a monad, consisting of an inner List monad with StateT packaging around it. Choose sensible names for the type, and unit, bind, and elevant functions of your StateT(List) monad. + What we do want you to do is to implement StateT(List). That is, plug in the implementations of the List monad's type, unit, and bind into the preceding definitions. That will be a monad, consisting of an inner List monad with StateT packaging around it. Choose sensible names for the type, and unit, bind, and elevate functions of your StateT(List) monad. You may want to write some operations for your List monad, such as: @@ -58,7 +58,7 @@ Is the `h` really essential to your solution? Or could you do everything with a 4. The next two exercises were taken from _The Little Schemer_ Chapter 8. - Suppose `lst` is a list of Scheme symbols (`'symbols 'are 'things 'written 'like 'this`; a list of them is `'(written like this)`). And that the behavior of `(remove 'sym lst)` is to remove every occurrence of `'sym` from `lst`. + Suppose `lst` is a list of Scheme symbols (`'symbols 'are 'things 'written 'like 'this`; a list of them is `'(written like this)`). And that the behavior of `(remove 'sym lst)` is to remove every occurrence of `'sym` from `lst`. Now we define a function `remove-co` which has the following behavior. It accepts as arguments a symbol, a list, and a handler `k` (I wonder why we named it that). `remove-co` calls `k` with two arguments: first, a list of all the sumbols in `lst` that aren't equal to `'sym`, and second, a list of all the symbols in `lst` that are equal to `'sym` (the handler might want to, for example, see what the length of the latter list is).