Homework #3


Readings:


Creating a Web Site

Part A
This is no longer required as part of this homework, but if you want to create a web page for yourself, the information is still here.


Getting Your Feet Wet

We want you to try your hand a writing some simple Scheme functions.  You will find reading the notes for Lectures 2-5 and the introductory chapter of An Introduction to Scheme and Its Implementation to be most helpful in understanding how to do this.

You can also get help from the online documentation for DrScheme.  

Remember to save your work in a file for submission.

Part B - 'cube' - (10 minutes)
Define a procedure called cube which finds the cube of its argument.

    > (cube 3)
    27

    > (cube (cube 2))
    
Notice: Uninitialized string offset: 3 in /users/home2/ta/cs330ta/public_html/cs330/inc/codeformat.php on line 115
512

Part C - 'new-sin' - (20 minutes)
Define a procedure called new-sin which operates as follows.  The built-in sin and cos functions in Scheme take their arguments in radians.  Using a conversion between radians and degrees your new-sin function will take two parameters: the number to take the sine of, and a test parameter telling whether the first is in degrees or radians.  If the first value is in degrees, the second parameter should be 'degrees, if the first value is in radians, the second argument should be 'radians.  If the second argument is invalid, you should return a string notifying the user of the error.

    > (new-sin 90 'degrees)
    1

    > (new-sin 1.570796327 'radians)
    1

    > (new-sin 45 'foo)
    "ERROR: invalid type for new-sin"

Note: Lecture 2 has a little information on how to define a function.  We'll cover functions much more in Lecture 4.  

Don't worry if your function doesn't evaluate to exactly 1 like in the example above.  There is a little round-off error whenever you do numerical calculations on a computer.


Create a Grade Account

Part D - (5 minutes)
In order for us to give you some grades, we need you to create a grade account.  You can do this by clicking on the "login" link in the menu bar on the left.  Follow the link that lets you create a new account and fill in the pertinent information.  This link will only be active for a couple of weeks, so please do it soon!


Turn Your Work In:

Please see the homework guidelines for more information about the homework policies and for more detail on using 330submit to turn in your work.

Your homework file for homework #3 should contain your Scheme functions from parts B & C.

You will want to comment out your entire homework file using Scheme's multiline comment delimiters.  The opening delimiter is #| and the closing one is |#.  The reason for doing this is that many of your homework assignments will be graded using a shell script and Scheme functions, but it makes no sense to try to evaluate text with the Scheme interpreter.  Of course, once you start writing Scheme functions in HW-6, you won't comment out the entire file.

Finally, use 330submit to turn in your homework file to the TA.


You must log in first before submitting homework assignments.

Instructions on submitting homework is here


Last updated at 9:53 am on Friday, August 27, 2004.