CSci 1301: Lab 1

The lab is done in groups of 2 or 3. You will use a pair-programming approach: one person is a "driver", i.e. types in program instructions, and the other person is a "navigator", i.e. guides the driver as to what to type and what to do next. The roles are switched every 10-15 minutes. For this lab it will be convenient to switch at the end of each exercise. If you are working in groups of three, the roles are: a "driver", a "navigator", and a "quality control" person. Again, make sure to switch frequently.

In the beginning of each file please write (in comments) the names fo all group members. Scheme comments are written like this:


; This is a comment

What to submit

At the end of the lab please send me and your group partner(s) all your Scheme files as e-mail attachments. My e-mail is elenam at morris.umn.edu. The subject of your e-mail must be "1301 Lab 1" followed by "Final" or "Not final", depending on whether this is a final submission or you are still working on it. If you need to finish it, make sure to set up a time with your group partner(s) to finish the lab.

When to submit

Due Friday, September 4, at 5pm. If you submit the final version during the lab, you are done.

Problem 1: Infix to prefix conversion. (8 points)

Please write Scheme expressions that correspond to the following infix expressions. Check your answers.

  1. 1.5 * 2 + 21/3
  2. (3 + 2 + 7)/(11 - 1 - 4)
  3. (3*(-2 +4))/(8/2 + sqrt(4))
  4. cos(0) + sin(0), where cos and sin are the cosine and sine functions, respectively. Scheme uses cos and sin as function names.

Problem 2: testing Scheme functions. (9 points)

Copy the following definitions into the Scheme definitions window.


(define a 5)
(define b 4)
(define c 3)
(define d 5)

Using the given variable definitions, find out what the following Scheme functions do: <=, max, eq?. Explain your answer in comments or in an e-mail message. For instance, you might want to test (<= a b) and (<= a d) and report your results.
What happens if the function is applied to more than two arguments? Please submit all of the tests that you tried to determine what the function does.

You may define other variables to test the functions, but please do not use any numbers directly.

Problem 3: fix errors in a Scheme program. (6 points)

Download the following file onto your desktop or into your home directory (create a subfolder if you prefer): broken.ss. Open the file in Scheme. There are multiple errors on this file. Fix the errors one by one. If no easy fix is available, just comment out the line by putting ; in front of it. The resulting file must work with no errors.

Problem 4: Define and test functions. (12 points)

Exercise 2.2.5 p. 11. If you are defining the four functions in the same file, give them different names. Make sure to test your functions carefully and submit your tests in addition to the functions. You may use expt for exponent.

CSci 1301 course web site.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.