From leavens@larch.cs.iastate.edu Thu Feb 2 19:28:22 2006 Date: Thu, 2 Feb 2006 19:28:22 -0600 (CST) From: Gary T. Leavens To: kinta@cs.iastate.edu Cc: Com S 342 TAs -- Kewei Tu , Ru He Subject: Re: Question about Hw3-Q4 Hi, On Thu, 2 Feb 2006 kinta@cs.iastate.edu wrote: > I am trying to implement procedure named append* > There is proble, because of number of argument. > I can implement procedure which take 1-n number of arguements. > However I have no idea about 0 -n arguements. > So please tell me brief idea of such procedure. > > (desfine append* > (lambda (lot) <- here is probleme > (body....))) You need to use the technique of the "variable arity procedures" that we discussed in class last week. It's described in section 1.3.3 of the Essentials of Programming Languages book. See also http://www.cs.iastate.edu/~cs342/lib342/code-examples.html#SchemeProcedures (this was wrong in the homework). Look in the subsection labeled "variable arity procedures". Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 --------------------------------- From leavens@larch.cs.iastate.edu Fri Feb 3 07:57:24 2006 Date: Fri, 3 Feb 2006 07:57:24 -0600 (CST) From: Gary T. Leavens To: yue@cs.iastate.edu Cc: Com S 342 , Com S 342 TAs -- Kewei Tu , Ru He Subject: Re: Question about HW3 -- fix to set-ops.scm Hi Yue, On Fri, 3 Feb 2006 yue@cs.iastate.edu wrote: > In Hw3, When I was trying to run set-ops.scm in DrScheme on my own mechine, it > gave the following error message: > > open-input-file: cannot open input file: "C:\Program > Files\PLT\collects\lib342\typedscm.ss" (The system cannot find the file > specified.; errno=2) > > I wonder how to fix this problem (DrScheme has worked fine for any other > problems) Oh, that's my fault. I see that I made a mistake in the set-ops.scm file. Please change line 8 from (module set-ops (lib "typedscm.ss" "lib342") to (module set-ops (lib "typedscm.ss" "typedscm") That is, change "lib342" to "typedscm" at the end of that line. This will fix the problem. I have fixed the hw342.zip file and the $PUB/homework/hw3/set-ops.scm file, so if you haven't started it, then you won't have problems, but if you have started it, just make the fix above. I'm sorry about the problem with this. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 --------------------------------------- From leavens@larch.cs.iastate.edu Sun Feb 5 16:14:07 2006 Date: Sun, 5 Feb 2006 16:14:07 -0600 (CST) From: Gary T. Leavens To: Corey J Mitchell Cc: Com S 342 TAs -- Kewei Tu , Ru He Subject: Re: problem 3 Hi Corey, On Sun, 5 Feb 2006, Corey J Mitchell wrote: > i have been working on this problem for hours and i can't figure out my bug. > i am getting extra parentheses somehow. i'm not sure if it is in my cons > expression or what. here is my code: > > [...] > > getfst just gets the first thing in the list that isnt a '() > inclst takes what getfst returns off the list > > i am not sure where i am going wrong here. I have a couple of suggestions for you. First did you try testing your helping procedures first? It's very useful to give yourself some examples to test them and see if they are doing what you think they should be doing. I find it helpful to document these in the comments or in a separate .tst file. I found that: (inclst '((w x) (a b c) (d e))) ==> ((x) ((a b c) (d e))) which doesn't seem to be doing what you want. I think it should return ((x) (a b c) (d e)) instead. It's interesting that: (inclst '((x) (a b c) (d e))) ==> ((a b c) (d e)) which doesn't seem correct. I think this points out what part of your code has the trouble. Second, you might try using the type checker. When I run the type checker on your code it says: : line 23: Arms of if expression have different types line 23: Left arm: (cdr lst) line 24: Right arm: (list (cdar lst) (cdr lst)) Left arm's type: (forall (T) (list-of (list-of T))) Right arm's type: (list-of datum) One of those two lines is involved in the error, I believe. I think line 24 is the one that is incorrect, because it's not giving the type one would expect in this case. Third, and probably more important, I don't see why you're using these helping procedures in any case. The problem is a recursion over flat list, whose elements simply happen to be lists themselves. It might help if you think about using the built-in scheme "append" procedure. If you use that, you'll see that you can treat the individual sublist as atomic entities in this problem. That means you don't have to recurse into those sublist. In other words, the problem is simpler than you're trying to make it. Consider the examples: (append-all '((3 7 10) (20 25 30) (5 4 3))) ==> (3 7 10 20 25 30 5 4 3) (append-all '((20 25 30) (5 4 3))) ==> (20 25 30 5 4 3) How could you use append to get the answer (3 7 10 20 25 30 5 4 3) from the answer for the related simpler example, which is (20 25 30 5 4 3), uising the car of the first example, which is (3 7 10)? Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 -------------------------- From leavens@larch.cs.iastate.edu Sun Feb 5 15:46:57 2006 Date: Sun, 5 Feb 2006 15:46:57 -0600 (CST) From: Gary T. Leavens To: kinta@cs.iastate.edu Subject: Re: Question about #6 Hi Shinji, On Sun, 5 Feb 2006 kinta@cs.iastate.edu wrote: > Yes I figured out about Question #3. Thank you You're welcome. > By the way I have another problem such is in Question #6 > > First I download newest "set-ops.scm" file, then I read " 3.3 Top-level Forms > Added To Scheme". > > I implemented set-add procedure to run the "set" procedure, such as (set 2 3 1) > When I try to call procedure set then it always said > > "reference to undefined identifier: set" > > Did I forget anything? You probably did (load "set-ops.scm") or just pressed the Run button in DrScheme. As the homework notes you have to do (require "set-ops.scm") in order to make the names defined in and provided by the module available for testing. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ----------------------------- From leavens@larch.cs.iastate.edu Sun Feb 5 16:43:59 2006 Date: Sun, 5 Feb 2006 16:43:59 -0600 (CST) From: Gary T. Leavens To: Shinji Kawasaki Subject: Re: What is output like? Hi Shinji, On Sun, 5 Feb 2006 kinta@cs.iastate.edu wrote: > Yes (require "set-ops.scm") was required, since I used it, procedure started Right. > The given code is using the (defrep) and > "We represent sets (of some type T ) by list (of the same type)" > > Is this mean sets act like list? The concept of this question is something like > "overroad" in C++/JAVA? It's not really like overriding in C++ or Java. It means that we think of the objects as sets, but they are actually lists. This is like in C++ or Java and when we think of an object as representing a person, but it's actually just a collection of integer and string fields. > And what is out put is set? > e.g (set 2 3 1) => (2 3 1) ? Yes that is possible. > And also set-add is inserting item into a set. > where should I insert new item? to index 0 or last index? > e.g (set-add 1 (set 2 3 )) => (1 2 3) > or > (set-add 1 (set 2 3)) => (2 3 1) > ? That is up to you. You have to make a decision that makes things work. We don't specify this decision in the homework. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 --------------------- From leavens@larch.cs.iastate.edu Sun Feb 5 20:34:20 2006 Date: Sun, 5 Feb 2006 20:34:20 -0600 (CST) From: Gary T. Leavens To: rmatus@cs.iastate.edu Cc: Com S 342 TAs -- Kewei Tu , Ru He Subject: Re: Homework #3 Hi Rich, On Sun, 5 Feb 2006 rmatus@cs.iastate.edu wrote: > I'm having a hard time getting anything going on this homework. For instance > problem #3, I have a feeling that it would be a double recursive type of > solution, in which you recursively go through each list, and while doing that, > you're recursively going through the elements of one list to get the elements > out. But I've spent a good 2-3 hours on it now and I am no closer to the > solution. I think this is because the idea you have described isn't really a good one for solving the problem. (The problem is a bit tricky because it looks like it's a double recursion because of the types. But in fact you can solve it with a flat recursion.) Instead, think about using the scheme append procedure. It's also helpful to think about related examples. For example: (append-all '((3 7 10) (20 25 30) (5 4 3))) ==> (3 7 10 20 25 30 5 4 3) (append-all '((20 25 30) (5 4 3))) ==> (20 25 30 5 4 3) How could you use append to get the answer (3 7 10 20 25 30 5 4 3) from the answer for the related simpler example, which is (20 25 30 5 4 3), using the car of the first example, which is (3 7 10)? > I'm just a bit bewildered how we had class Tuesday which partly was spent on the > test, and the the rest of which didnt' seem to be spent on any of this for the > homework, followed by a class on Thursday in which we had a test... and then > have this homework due? > > I'm not sure what I'm working towards, or what I'm supposed to learn here. I > don't feel I've been exposed to what I need, and it is really confusing trying > to move forward. Sorry about that. What we did in class Tuesday was about syntax abstraction which isn't really much on this homework. This homework is mostly about the flat recursion over lists material we did on January 19. See also the readings from the homework: ESSENTIALS OF PROGRAMMING LANGUAGES: pages 1-19 (you can skim section 1.1) THE LITTLE SCHEMER, CHAPTER 3 CODE EXAMPLES WEB PAGE, http://www.cs.iastate.edu/~cs342/lib342/code-examples.html#Little2 http://www.cs.iastate.edu/~cs342/lib342/code-examples.html#Little3 http://www.cs.iastate.edu/~cs342/lib342/code-examples.html#SchemeProcedures FOLLOW THE GRAMMAR HANDOUT http://www.cs.iastate.edu/~cs342/docs/follow-grammar.pdf Does that help? Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ------------------------------ From leavens@larch.cs.iastate.edu Mon Feb 6 11:35:39 2006 Date: Mon, 6 Feb 2006 11:35:39 -0600 (CST) From: Gary T. Leavens To: Chris Cornelison Cc: Com S 342 TAs -- Kewei Tu , Ru He Subject: Re: CS342 - HW3 Hi Chris, On Mon, 6 Feb 2006, Chris Cornelison wrote: > In problem 6, If I implement set-add, stub out the rest of the > functions, and hit the run button, Scheme accepts the definitions. > However, if I then try to test just 'set' and 'set-add', I get errors... > >> (set 2 3) > . reference to undefined identifier: set > > Should I be able to incrementally implement and test? > > I am using the departmental machines. I think this is a simple problem. You probably used the "Run" button or did (load "set-ops.scm") instead of using the Run button and then doing (require "set-ops.scm") Unless you do the (require "set-ops.scm"), you can't access the names in the module. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ----------------------------------- From leavens@larch.cs.iastate.edu Mon Feb 6 14:01:17 2006 Date: Mon, 6 Feb 2006 14:01:17 -0600 (CST) From: Gary T. Leavens To: Chris Cornelison Cc: Com S 342 TAs -- Kewei Tu , Ru He Subject: Re: CS342 - HW3 Hi Chris, On Mon, 6 Feb 2006, Chris Cornelison wrote: > In problem 5, I'm having difficulty getting started. > > Should I be able to make use of append* somehow, or is > there some special procedural feature I should be trying to use, for > example apply and var-arity? This is the probelm about append-map. For that problem, you don't have to use append* in your solution. While that is possible, doing so is tricky. We just used append* in specifying what the procedure is supposed to do, but you don't have to use append* in the solution. You might think about using append in the solution instead. > I guess I don't quite understand the type declaration either. Is it > saying... append-map : (forall (S T) (-> ((-> (S) (list-of T)) (list-of S)) (list-of T)))) > A procedure that takes x and returns a list-of T, where x is a procedure > that takes a function and a list-of T and returns a list-of S? Well, I would read it as saying: append map is a procedure such that, for all types S and T, append map takes 2 arguments: - the first, of type (-> (S) (list-of T)), is itself a procedure that takes something of type S and returns a list of elements of type T, and - the second, of type (list-of S), is a list of elements of type S and returns a list of elements of type T. > If my list-T is (e1 e2 ...) then is the list-of S something like ((f e1) > (f e2) ...)? The argument isn't the list of T. Let's take one of the examples in problem 5 to illustrate: (append-map (lambda (n) (if (= n 3) '() (list n))) '(3 4 2 3 7)) ==> (4 2 7) Here the first argument is (lambda (n) (if (= n 3) '() (list n))), which has type (-> (number) (list-of number)), so S = number and T = number. The second argument is '(3 4 2 3 7), which has type (list-of number) = (list-of S), since S = number. The result is also a list of numbers, which matches (list-of T), since T = number. Try this exercise of explaining the type for the call (append-map (lambda (n) (if (even? n) '(#t) '(#f))) '(5 4 1 6 4 1)) ==> (#f #t #f #t #t #f) Let me know if that helps. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 From leavens@larch.cs.iastate.edu Mon Feb 6 22:01:08 2006 Date: Mon, 6 Feb 2006 22:01:08 -0600 (CST) From: Gary T. Leavens To: Nick Retzl Cc: Com S 342 , Com S 342 TAs -- Kewei Tu , Ru He Subject: Re: how to incrementally develop with a module (HW3 #6 problem) Hi Nick, (For others, this is in response to several questions about how to work in a module, like set-ops, and not have to do all the functions before testing any of them...) Ah, I see now what's causing the problem. When you load your module you get the message: module: provided identifier not defined or imported in: set-intersect This is because you don't have a (define ...) form defining the name set-intersect, or several others in the provide list at the top of the module. Scheme requires a definition for each name in the provide list at the beginning of the module. (Note that the deftypes don't affect this at all.) So here's what you can do. Say you want to only implement and test set-add. Then make the provides list look like: (provide the-empty-set set-empty? set-size set set-member? set-one-elem set-rest set-subset? set-equal? set-add ;set-remove ;set-union ;set-minus ;set-intersect ;set-union-list ;set-union* ) and that will allow you to only implement set-add (in addition to the ones we have provided for you). This is a good choice for testing at first. Note that when you implement the next one, say set-remove, you have to uncomment the corresponding name (set-remove) in the provide list, otherwise it won't be available when you try to test it. Let me know if that helps. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 --------------------------------------- From leavens@larch.cs.iastate.edu Tue Feb 7 18:20:34 2006 Date: Tue, 7 Feb 2006 18:20:34 -0600 (CST) From: Gary T. Leavens To: bkshmidt@cs.iastate.edu Cc: Com S 342 TAs -- Kewei Tu , Ru He Subject: Re: COMS 342 HW3 #12 Hi Brian, On Tue, 7 Feb 2006 bkshmidt@cs.iastate.edu wrote: > I am having problems with #12 on HW3. I am able to get down to the bottom of > the > recursion can get the first output from applying the function. However I am > having problems getting the function that is given to be applied to the return > value from the base case. As the homework says, for argument 0, the result is the identity function (which is the function that just returns its argument). ... This is a numerical recursion, so the base case is something about numbers. There are no lists involved, so there is no need to use car or cdr. No need to use apply either in this problem. The outline for such a numerical recursion is given in the Little Schemer, chapter 4. (define iterate (lambda (f n) (cond ((zero? n) ___________) (else (__________ (iterate f (- n 1))________))))) The base case is given by examples like: ((iterate (lambda (n) (+ n 1)) 0) 5) ==> 5 which says that (iterate (lambda (n) (+ n 1)) 0) returns a procedure that, when applied to 5, returns 5. To figure out what to do in the inductive case, think about related simplier examples, which for nubmers are 1 smaller. The first several examples in the homework are related simplier examples, since 3 is related to 4 by being 4-1. ((iterate (lambda (n) (+ n 1)) 4) 100) ==> 104 ((iterate (lambda (n) (+ n 1)) 3) 100) ==> 103 So, if n is 4, we are recursing on 3, and hence we have to figure out how to get a function that takes 100 and returns 104 from the answer of the recursive call, which is a function that takes 100 and returns 103, and the arguments (lambda (n) (+ n 1)) and 4. This tells you how to take one more step, based on the recursive call. Does that help? Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ------------------------------------ From leavens@larch.cs.iastate.edu Wed Feb 8 10:56:20 2006 Date: Wed, 8 Feb 2006 10:56:20 -0600 (CST) From: Gary T. Leavens To: Chris Cornelison Cc: Com S 342 TAs -- Kewei Tu , Ru He Subject: Re: CS342 - HW3 problem 12 Hi Chris, On Wed, 8 Feb 2006, Chris Cornelison wrote: > I am having trouble with problem 12. > > I read the reply in the Q&A regarding this problem, and I understand the > numerical recursion of problem 11 and the examples of producing + from > add1 and sub1 in Little Schemer, but I still can't get my head around > this problem. > > I can't picture what the returned procedure looks like. > > In the example > ((iterate (lambda (n) (* n n)) 3) 5) ==> 390625 > > (* 5 5) ==> 25 > (* 25 25) ==> 625 > (* 625 625) ==> 390625 > > which is the result of recurring 3 times. I just can't see > how the 5 gets connected to (lambda (n) (* n n)). In an improtant sense, all procedures look like (lambda ...). Now, let's take what we have to work with, which is (lambda (n) (* n n)), and modify it to get what we want in this case. First, ((lambda (n) (* n n)) 5) = (* 5 5) = 25 Now we have to get a procedure that, when given 5 as an argument, produces 625, and we have to do it from (lambda (n) (* n n)). What can we do with procedures? We can apply them, and we can make new ones with lambda. The combination lets us compose them. Here we want to multiply the result by itself, which is what our procedure (lambda (n) (* n n)) does. So let's compose it with itself. To do that, we need to make a new lambda, so it will look like: (lambda (x) ... (lambda (n) (* n n)) ... (lambda (n) (* n n)) ...) Recall from class that we wrote compose as (lambda (f g) (lambda (x) (lambda (f (g x))))) here we want to use (lambda (n) (* n n)) as f and g, so we get (lambda (x) ((lambda (n) (* n n)) ((lambda (n) (* n n)) x))) or if you like: (lambda (x) (let ((f (lambda (n) (* n n))) (g (lambda (n) (* n n)))) (f (g x)))) Trying these out, you can see that ((lambda (x) ((lambda (n) (* n n)) ((lambda (n) (* n n)) x))) 5) = ((lambda (n) (* n n)) ((lambda (n) (* n n)) 5)) = ((lambda (n) (* n n)) (* 5 5)) = ((lambda (n) (* n n)) 25) = (* 25 25) = 625 So this shows the form of the procedure that should be returned. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 -------------------------------- From leavens@larch.cs.iastate.edu Wed Feb 8 11:41:07 2006 Date: Wed, 8 Feb 2006 11:41:07 -0600 (CST) From: Gary T. Leavens To: Com S 342 , Com S 342 TAs -- Kewei Tu , Ru He Subject: More hints on HW3 #12 in Com S 342 Hi all, Several students have asked me about problem 12 on homework 3. Since this didn't get covered in discussion sections (due to a missed email), I think it is helpful to give some more hints. I put several hints in the Q&A for the class. What is below is another example that shows how to work such problems. In essence, such problems are a combination of numerical recursion (like The Little Schemer's chapter 4) and the kind of thinking we did in class for creating functions like compose and twice by generalizing from examples. So, as the promised example, suppose we want to write a procedure, expt-maker: (-> (number) (-> (number) number)) that takes a non-negative integer, n, and returns a procedure that takes a number, x, and multiplies x by itself n times. For example: ((expt-maker 0) 7) = 1 ((expt-maker 0) 95) = 1 ((expt-maker 5) 10) = 100000 ((expt-maker 4) 3) = 81 ((expt-maker 3) 3) = 27 ((expt-maker 2) 3) = 9 ((expt-maker 1) 3) = 3 ((expt-maker 0) 3) = 1 A solution recognizes from the first and last examples that ((expt-maker 0) x) = 1 which is the base case, so that (expt-maker 0) returns the function that when applied to x, returns 1, i.e., (lambda (x) 1). That is, (expt-maker 0) = (lambda (x) 1) For the inductive case we have to look at related simplier examples. Since the argument to expt-maker is a number, we look at a number and the next smaller number, like: ((expt-maker 4) 3) = 81 ((expt-maker 3) 3) = 27 Now we can ask: how do we get 81 from the answer for the recursive call (27) and the other information. It works like this... ((expt-maker 4) 3) = 81 = (* 3 27) = (* 3 ((expt-maker 3) 3)) So we conclude that ((expt-maker 4) 3) = (* 3 ((expt-maker 3) 3)) Now, let's generalize, calling the 4, that is the argument to the inner call n, and calling 3 that is the outer argument x. ((expt-maker n) x) = (* x ((expt-maker (- n 1)) x)) This tells us the general form of the inductive case. Notice also the recursive call inside: (expt-maker (- n 1)), So we see that (expt-maker n) returns a function that, when applied to any arugment x, returns (* x ((expt-maker (- n 1)) x)). That is: (expt-maker n) = (lambda (x) (* x ((expt-maker (- n 1)) x))) So we fit this into the outline for numerical recursion (define expt-maker (lambda (n) (cond ((zero? n) _________________) (else (_________ (expt-maker (- n 1))___________))))) by using the information about the base and inductive cases we gained from analyzing and generalizing the examples above: (define expt-maker (lambda (n) (cond ((zero? n) (lambda (x) 1)) (else (lambda (x) (* x ((expt-maker (- n 1)) x))))))) Incidentally, one can also pull out the repeated (lambda (x) ...) from the cond, and get: (define expt-maker (lambda (n) (lambda (x) (cond ((zero? n) 1) (else (* x ((expt-maker (- n 1)) x))))))) However, in this version you perhaps can't see the outline for numerical recursion as clearly. Still, both work. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ---------------------------------- From leavens@larch.cs.iastate.edu Wed Feb 8 11:55:07 2006 Date: Wed, 8 Feb 2006 11:55:07 -0600 (CST) From: Gary T. Leavens To: njretzl@cs.iastate.edu Cc: Com S 342 TAs -- Kewei Tu , Ru He Subject: Re: COMS 342 Question 13 Hi Nick, On Wed, 8 Feb 2006 njretzl@cs.iastate.edu wrote: > I found my mistakes, thanks for the help. Good. > One other quick question though, > in problem 13, how do you get the additional lists to appear on the next line? We just wrote them like that to make it clearer. Your output won't look the same, which is fine, as long as it has the right values. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 --------------------- From leavens@larch.cs.iastate.edu Wed Feb 8 18:22:04 2006 Date: Wed, 8 Feb 2006 18:22:04 -0600 (CST) From: Gary T. Leavens To: Nick Retzl Cc: Com S 342 TAs -- Kewei Tu , Ru He Subject: Re: CS 342 problem 15 Hi Nick, On Wed, 8 Feb 2006, Nick Retzl wrote: > I have a question about the last problem (problem 15). What do the > exactly mean by "rewrite the grammar"? I'm assuming we have to change > the grammar on page 6 but not sure really how to approach it. Also what do > they mean indicate the cnages to the "above derivation" ...? (this is in the > same question in the text) Any help would be apprecaited. Thanks again! Yes, the grammar is the one on page 6. Introduce a new nonterminal for each place that the Kleene * or + is used. The "above derivation" refers to the one on page 7 of (#t (foo . ()) 3). Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 -------------------------