Frequently Asked Questions, CS 115-03, Fall 96


  1. QUESTION [Wed Oct 2 22:49:08 1996]:

    For the exercises that do not involve MacGambit (e.g. exercises 4 and 5), is it necessary to type up the solutions and put them in our folder in the homework drop box, or are hard copies alone sufficient for these problems?

    ANSWER [Oct 3, 10:20 a.m.]:

    If the problem does not say to use MacGambit, you are not required to. Hard copies alone, written neatly or typed, will suffice. However, often it will help you to use MacGambit anyway. If you do use MacGambit, then do put your files for that problem in the Homework DropBox.


  2. QUESTION [Wed, 2 Oct 1996 23:38:36]:

    I just searched all over the HTTP for Chapter one...it kept freezing when I tried to open the links, but I couldn't find the problems--are they in just in the textbook? Or am I just missing them on the web page...

    ANSWER [Oct 3, 10:25 a.m.]:

    If you follow the link in the CS 115-03 home page for Chapter 1, then scroll to the end of that page, there is an index. The problems are at the end of the section "Conditional Expressions and Predicates". I will also place some photocopies of the problems outside my office door for you to pick up in case the Web site for the textbook (located at MIT) freezes up.


  3. QUESTION [Mon Oct 7 16:45:10 1996]:

    Your notes for the Pascal Triangle function suggest that when we input

    :(pascal-triangle 5 7)

    as a test case, we should get

    *** Error -- bad input to pascal-triangle

    Some mathematicians would define (pascal-triangle 5 7) as zero, though. Do you want us to handle this case and return a zero, or do you want us to make the procedure return an error?

    If part of the purpose of this assignment is to see whether we know how to trap errors, are there other cases it's important to trap, too (i.e. do I need to worry about non-integer inputs, too, for the purpose of this assignment? What about row < 0?)

    ANSWER [Tues, Oct 8, 9:35 a.m.]:

    You may assume the inputs are both integers. You may include a test for non-integers if you desire, and if you can figure out how to via the MacGambit on line help or the textbook, but you are not required to make this error check.

    I want the case of (pascal-traingle 5 7) to return an error, and not 0. If the row or position argument to pascal-triangle is less than 1, the procedure should produce an error message.


  4. QUESTION [Wed Oct 9, 2:45 p.m. 1996]:

    For the Sierpinski exercise, if I choose my initial point x outside the triangle, isn't it possible my procedure will plot points outside the triangle, which is incorrect?

    ANSWER [Wed Oct 9, 3:15 p.m. 1996]:

    For the Sierpinski triangle exercise, you can choose any initial point x that you want. If you choose one outside the triangle, you will get a few extraneous points, but most of the points will be plotted correctly. To avoid these extraneous points, you can choose your intital x to be one of the 3 corner points of the triangle.

    A hint: Remember that the clauses of a conditional can have more than one expression to evaluate. If a certain clause is true, you might want to draw a certain point, and then make a call to a procedure.


  5. QUESTION [Tue, 15 Oct 1996 01:45:39]:

    As I was coding up Exercise 1.22, I noticed that when I had called (display), a number always followed after it. Is there any way to suppress that number? I couldn't find any way to do it in the Online help.

    ANSWER [Tue, October 15, 10:15 a.m., 1996]:

    The short answer is that for this problem, you don't need to use "display" in your code, because the code that displays the time is already provided for you. Your procedure should call "timed-prime-test" many times; at most the last call should be affected by the number returned by "display", and we won't take off points for this.

    Here is the longer answer. The return value of (display ) is the number of characters in the displayed expression. We are usually not interested in the return value, but rather in the side effect of display, which is to write its argument to the screen.

    If the display is not the last item evaluated, its return value won't be printed on the screen. So if you want to write "Hello There." to the screen, without the number "12" appearing after it, you could do this:

    (begin 
      (display "Hello There.")
      '.) 
    

    The "begin" statement combines statements, and returns the return value of the last item. Here, the last item is a single quote followed by a period, which returns the symbol ".", which gets printed to the screen as the return value for the whole begin statement. I will be talking about "begin" and "quote" more in class soon.


END OF QUESTION LIST for CS 115-03, FALL 1996
[back] CS 115-03 home page