From leavens@larch.cs.iastate.edu Tue Mar 8 22:44:12 2005 Date: Tue, 8 Mar 2005 22:44:12 -0600 (CST) From: Gary T. Leavens To: Matthew J. Ring Cc: Com S 342 TAs -- Brian Patterson , Daniel Patanroi Subject: Re: Hw7 Hi Matt, On Tue, 8 Mar 2005, Matthew J. Ring wrote: > Do you want us to print out the entire definitions file for question 3? You can print out the definitions once, when you hand something in, if the changes are clearly marked (use comments). > Also, can you elaborate on Question 4? I'm not quite sure what exactly the > question is asking from me. Sure, for example are subexpressions evaluated in left to right order, or right to left, or inside out, or randomly? 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 Mar 9 15:21:37 2005 Date: Wed, 9 Mar 2005 15:21:37 -0600 (CST) From: Gary T. Leavens To: Matthew J. Ring Cc: Com S 342 TAs -- Brian Patterson , Daniel Patanroi Subject: Re: hw7, q5 Hi Matt, On Wed, 9 Mar 2005, Matthew J. Ring wrote: > First, am I correct that the list, cons, car, etc. should be written as > primitives? Yes. > There is an example for "list", but not for the rest. So, car(3, > list(3,4,5)) ? would be an error. Car takes 1 argument, as in Scheme. You could write, for example, car(list(3,4,5)) and that would return 3. See the test cases in $PUB/homework/hw7/ for more examples. > Also, when writing the list procedure, I need a recursive procedure to > generate the list. I didn't need one. :-) > Is there a way I can write a helper procedure that is not > visible to anybody running this (this is mostly for my own preference), kind > of like a "private" procedure? You can use letrec if you wish. In any case, Scheme procedures in your file are not available to users of the defined language. 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 Thu Mar 10 09:02:34 2005 Date: Thu, 10 Mar 2005 09:02:34 -0600 (CST) From: Gary T. Leavens To: Andrew Suckow Cc: Com S 342 TAs -- Brian Patterson , Daniel Patanroi Subject: Re: HW7 Q5 Hi Andrew, On Thu, 10 Mar 2005, Andrew Suckow wrote: > Hi, I'm confused about how to implement the list and cons primitives that we > are supposed to add to the interpreter for question 5. I'm not sure what > else to say-I simply don't get it. The Q&A online hasn't cleared anything > up for me either. One way to think about it is that the list primitive takes a list of arguments, and makes a list out of them. In Scheme, we could write list as (define list (lambda args args)) using the variable argument lambda. The cons primitive takes 2 arguments, so like + and *, you will need to extract them from the list of arguments that apply-primitive gets. Then like the way the interpreter works with + and *, you will use Scheme's cons operator to do the work. Come by my office after 10am and before noon if you can and we can discuss it if this doesn't 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 Mar 21 14:46:04 2005 Date: Mon, 21 Mar 2005 14:46:03 -0600 (CST) From: Gary T. Leavens To: Matthew J. Ring Cc: Com S 342 TAs -- Brian Patterson , Daniel Patanroi Subject: Re: hw7 misc questions Hi Matt, Brian's already answered, but here are more details. On Mon, 21 Mar 2005, Matthew J. Ring wrote: > What does "separated-list" do in > > (expression > (primitive "(" (separated-list expression ",") ")") > primapp-exp) > > Is it similar to a split() function in Java or C#? No, it describes a grammatical production that is a list of the given nonterminal, separated by the given separator token. So in this case, a primapp-exp looks like ::= ( ) ::= | ::= | , > Also, I'm a little hung up on implementing the Kleene Star notation for the > cond-exp for hw7, question 8. Any hints? Could I use something from the > first question in my solution? The "arbno" in the grammar given in the problem already does parsing of the Kleene star. To implement the abstract syntax tree corresponding to it, one uses a list, or, in this case, two lists, as in the box below the grammar given in exercise 3.13 on page 81 of the text. See how the grammar on page 82 is implemented for an example. 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 patterbj@cs.iastate.edu Tue Mar 22 21:16:11 2005 Date: Tue, 22 Mar 2005 21:16:12 -0600 From: Brian Patterson To: Matthew J. Ring Cc: cs342s@cs.iastate.edu Subject: Re: hw7, q12 The explanation for problem 12 hits this (although we mean problem 8 more than problem 5) - you can use either 3-4 or the modified 3-1.scm. If you use 3-4, you need to add the list processing stuff you wrote for 3-1 - I used my 3-1 and copied over the let stuff from 3-4. In any case, the problem explicitly says, "You won't need the let primitive". Brian On Mar 22, 2005, at 6:47 PM, Matthew J. Ring wrote: > Should I be using 3-4.scm or my modified 3-1.scm file that I have been > editing for a while now? It doesn't really specify in the homework > problem, but I have a feeling that I need to use "let" in this > problem. >   > If using 3-4.scm, is there anything from previous questions (other > than question 5) that I would need to copy over to the new file? >   >   > Matthew J. Ring > www.theringworx.com >   >