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.

You might want to open these instructions in a separate tab.

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

``````
; This is a comment
``````

Recall that Scheme and Racket are the same language. I use the two names interchangeably.

What to submit

At the end of the lab please send me and your group partner(s) all your Racket 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 3, 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 (Racket) 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 (Racket) 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: `<=, eq?, max`. 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 program. (6 points)

Download the following file onto your desktop or into your home directory (create a subfolder if you prefer): lab1.rkt. Open the file in DrRacket. 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.

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.