In this assignment you will create programs which put to use some of the week’s topics. You’ll also be introduced to some useful new ways of thinking about Scheme code. By the end of the assignment, you should be comfortable with
- The DrRacket interpreter
- Writing Racket functions
- Using recursion with lists
- Writing tests for Racket functions
Your implementations of the following functions should all be placed in a single Racket file named hw1.rkt
. The corresponding tests for each function should be in a second Racket file named tests.rkt
.
The start of each file should be
#lang racket
; Your name(s) here.
Preliminaries
First, download and install Racket. Select the Racket
(not Minimal Racket
) distribution for your platform (almost certainly the 64-bit version for your operating system) and select the Regular
variant.
If you don’t already have a GitHub account, make one. (As a student, you can get additional GitHub benefits such as unlimited private repositories here, but you don’t need to for this course. All of your repositories will be private to you, your partner (if you have one), and course instructors.)
You’ll need Git installed in order to download and submit assignments. On macOS, Git is included with Xcode which can be installed from the App Store. On Linux, Git can be installed using your distribution’s package manager. You can install any of the many other Git tools instead, including GitHub Desktop on macOS and Windows.
Click on the assignment link. If you’re working with a partner, one partner should create a new team. The second partner should click the link and choose the appropriate team. (Please don’t choose the wrong team, there’s a maximum of two people and if you join the wrong one, you’ll prevent the correct person from joining.)
Once you have accepted the assignment and created/joined a team, you can clone the repository on your computer by following the instruction and begin working. But before you do, read the entire assignment and be sure to check out the expected coding style.
Be sure to ask any questions on Piazza.
Coding style
For all of the Racket code you write, you should follow the standard conventions. In particular,
- You should let DrRacket indent your code. You can re-indent a line of code at any time by pressing tab. The
Racket
menu contains a Reindent All
item which you can use to reindent the entire file. - Closing parentheses and brackets should not appear on lines by themselves (as you might do with
}
in C or Java). For example, a function to compute the arithmetic mean of two numbers might be written as (define (mean x y)
(/ (+ x y) 2))
or
(define (mean x y)
(/ (+ x y)
2))
but not as
(define (mean x y)
(/ (+ x y)
2
)
)
Submission
To submit your homework, you must commit and push to GitHub before the deadline.
Your repository should contain the following files
It may also a .gitignore
file which tells Git to ignore files matching patterns in your working directory.
Any additional files you have added to your repository should be removed from the master
branch. (You’re free to make other branches, if you desire, but make sure master
contains the version of the code you want graded.)
Make sure you put your name (and your partner’s name if you’re working with one) as a comment at the top of each file.
Finishing up
Make sure you wrote tests of all of these, the test suite for each function is included in the all-tests
test suite, and your tests pass. For reference, my solution involves 66 tests in total and when I run (test/gui all-tests)
, I get this.
Once you have finished (or better yet, frequently as you’re working), you need to push your code to GitHub since this is what we’ll use for grading. So double check that you’ve included your name and the name of your partner (if you’re working with a partner) in both files and git add/commit/push.
$ git add hw1.rkt tests.rkt
$ git commit
$ git push