COMP 210 Homework #1

Fall 2002

Due Wed., Sept. 4. at the start of class

Before you start the homework, you should remind yourself of our General Advice,
Advice on Homeworks, and Grading Guidelines. All are available from the class web
site ( http://www.owlnet.rice.edu/~comp210) .

 

You should turn in one copy of the homework for your team (not one per person) .
Clearly print the names of both team members on the homework. Staple together all of
the pages (before you get to class).

 

Read Sections 1 through 4 of the book.

 

  1. ( 5point) Put the following expressions into Scheme s prefix notation. Type the
    results into Dr. Scheme s interactions window and see if you get the expected results.
    1. 17
    2. 17 * 12
    3. 170 * 5 * 12
    4. 5 * 6 * 7 * 8

  2. ( 20 points) Hand evaluate the following Scheme expressions. After you are done,
    type them into the interactions window in Dr. Scheme to confirm your results.
    1. (- (* 3 5) 20)
    2. (* pi (* 10 10))
    3. (+ 73 false)
    4. (/ 12 0)

  3. ( 15 points) Go to the definitions window and type in the three functions from Lecture 1:
    owes, dough-area, and pizza-topping-area. Click the execute button. Go to the
    interactions window, and invoke each function on two different arguments. Hand in your code, your tests and the results.

  4. ( 10 points) Write a function Rectangle that consumes a height and a width, and
    produces the area of a rectangle of that size. Be sure to write down the contract and
    purpose. Test your program on several inputs. Hand evaluate the expression (Rectangle 10 15)
    (Here is a sample hand evaluation, to give you an idea of what we want.)

50 points total