CS 3723
Programming Languages 
Fall 2013
  Questions and Corrections,   
  with Responses   

Please direct questions or corrections or comments to the following email address, where δοτ is a "dot" and ατ is an "at-sign":   < nealδοτwagnerατgmailδοτcom >


  1. Question (Mon Sep 16 16:35 CDT 2013): Are the meta-symbols including + ,- , *, / , |, ^, (, ) and arrow (--->) ?

    Answer: No. Sorry, but this isn't close to correct. This is question 4a of Recitation 3.

    Metasymbols are symbols used to construct the grammar rules themselves. They are the same for all grammars and languages, assuming a given notation. So far, the only metasymbols we have used are: ---> | and ε (the empty symbol).  Later we will also use { and } as metasymbols. There are many different ways to create CF grammars, all equivalent. Some of these use many additional Metasymbols.

    Every symbol to the left of an arrow in a grammar rule is a non-terminal. Besides the metasymbols and the non-terminals, all other symbols are terminal symbols. So in your list + - * / ^ ( ) are all terminal symbols.


  2. Question (Wed, Sep 18, 2013 at 2:22 PM): So do we only turn in part A physically for Recitation 3? Or what can we turn in as a physical paper?

    Answer: Please always turn in by email everything except drawings or other materials that are difficult for you to email. This includes emailing all the pieces of part A except such drawings. Never turn in whole questions (or the whole recitation) as physical paper. The deadlines still apply to what your submit, but you can turn in the extra papers, if any, at the next class period.


  3. Question (Wed, Oct 2, 2013 at 1:12 PM): Related to Recitation 6: For the < uppercase rule, are we supposed to only look for B,N and T or any uppercase? Like the past parsers, is this only to output success or failure?

    Answer: You should accept any uppercase. (Which uppercase letters are accepted is a semantic issue.) The result should be either success or failure, but you should produce some sort of debug output, partly to convince yourself that it is working. Today I'm going to assemble some simpler output.


  4. Question (Wed, Oct 30, 3:30 pm): For Recitation 9, question 9.4 a.: Is the following OK for an answer, or should I use a loop function to do it?

      > (+ 1 (/ 1 2) (/ 1 3) (/ 1 4) (/ 1 5) (/ 1 6) (/ 1 7) (/ 1 8) (/ 1 9) (/ 1 10))
      7381/2520

    Answer: No, this is not all right, and it is also not acceptable to use a loop function. Instead you must use recursion to solve this problem, by writing a recursive function with one parameter n. The idea is that the sum of n terms is 1 if n is 1. Otherwise the sum of n terms is the sum of n-1 terms plus 1/n.


  5. Question (Wed, 06 Nov 2013 7 pm): Several students are having trouble with Questions 10.3 of Recitation 10, the one that asks for a reverse1 function: "I am trying to do the reverse1 function but it keeps printing too many parentheses. How do I get rid of them?" This student wanted to tack the car onto the end of the reversed version of the cdr of a list. He uses the list function for this and, starting with (a b c), he ends up with ((C B) A). Another student uses cons for the same problem and ends with (((NIL . C) . B) . A).

    Answer: To tack a a onto the end of a list (b c), you can use append. But append won't work right with an atom a, so you have to turn a into a list, and you can use the list function to do this: > (list 'a) is (a). (There are always many ways to do things in lisp. This is just one way. Students often come up with solutions that are better than mine.)


  6. Question (Mon, Nov 25, 2013, 7 PM): In Recitation 12, you mention "m, the number of tips to skip over in drawing a line". What exactly does this number do? What does it mean by the number of tips to skip over? Also, is there an example of taking input for these .ps files?

    Answer: I have restated some of the directions for Recitation 12 in order to make them clearer. In particular, I shouldn't have said "number of tips to skip over", but instead the "number of tips to skip ahead". Looking at the stars, say the second one, and its numbers 10 and 3, surely the meaning is clear. I don't know how to read numbers into a postscript file from the outside (from the system). Instead, the parameters to the function (call it star) that draws a star should be Postscript parameters: these are numbers (and other values such as strings) that are pushed on the Postscript stack before calling the function. Inside the function, it will access the numbers or make use of them from the stack. The third and fourth versions of the overlapping boxes example show this for the function box.


Revision date: 2013-11-25. (Please use ISO 8601, the International Standard.)