You’re encouraged to submit as frequently as you want, treat the handin server as a remote safe storage for your homework. You can also use the handin button to retrieve the last version of the code that you submitted.
Begin your work by getting some minimal code that can be submitted, so you can start using the handin server as such a storage. This usually means having a number of definitions in the code. Make sure that these bindings have comments next to them, making it clear that they’re a yet-unimplemented part of the homework.
The server will warn you about a penalty for incomplete coverage as long
as you don’t have enough tests — you should accept this penalty to have
your code saved, and then continue working on getting the code to work
and the tests to cover your code. Remember the
scratch option if you
want to save a checkpoint that cannot be submitted (because it cannot
even be evaluated by the server).
But note that the server warns you about incomplete coverage for a reason! When it does so, be aware of the high penalty that you will get automatically — so don’t just accept it blindly!
If you just can’t get some part(s) of a homework done, do not give up on getting complete coverage since that will result in a heavy penalty on top of the missing part. If all fails, write a stub function and a test to get the stub marked as covered, with a comment saying that you did that to avoid the coverage penalty.
scratch “homework” accepts anything you submit (the server will not
evaluate the code). You can use it to test that everything is working,
and as a kind of a remote file storage for your code. Note that the
handin button can be used to retrieve the file that you submitted last,
making it possible to conveniently work on the remotely saved file.
(= (length l) 0)is equivalent to
(null? l), but the
lengthwill scan the whole list (so it is O(n) instead of O(1)). Also,
(append l (list x))to add an element to the end of the list will scan the whole list and copy it, which is much more expensive than the O(1) cost of
(cons x l).
You should be using the “Racket” language throughout most of the course, with a language specification line that looks like:
In the language selection dialog, click the “Show Details” and choose the “Syntactic test suite coverage” option to see which parts of your code are not covered by tests yet (they will be painted red), or when you have complete coverage (when the colors stay the same after running).
To conveniently navigate Racket code, you can use
Alt with the arrow
keys to move over an expression — complete identifier, number, string,
or a parenthesized expression.
Many experienced Racket programmers never count parenthesis, they don’t
even need a paren-highlighting editor like DrRacket to do that. The
trick is to write your code in such a way that parentheses are always
balanced — never insert an open paren, bracket, brace, or double-quote
without inserting the closing token too. DrRacket makes this easy to do:
Alt while you’re typing one of these open tokens, and DrRacket
will insert the matching closing one too. (On macOS, hit
the open token.) If you do this while some text is selected, it will get
surrounded by the delimiters.
In addition to line comments (
;), and block comments (
Racket has expression comments:
#;. When the reader sees a
in the input, it will read the following expression, and discard it.
This is especially convenient while debugging, since it gives you a
convenient way to completely ignore an expression.
DrRacket has a lot of key bindings, you can see a list of active key
bindings from the
In DrRacket, the open-square-bracket key (
[) is actually a magic key
that guesses which paren shape should be used. In some cases you won’t
want that, and you can use control and the key to force the square
bracket shape. (But note that using the balanced paren keys is always a
Instead of discovering too late that you have lines that are too long, you can make DrRacket show you a “width guide”. Turn in on in Preferences ⏵ Editing ⏵ General Editing ⏵ Maximum character width guide. It is also generally useful while working since it’s yet another indication that your code is getting too complicated and should be split into smaller functions.
You don’t have to use DrRacket as your editor if you don’t want to. You can use any editor for your editing, and only switch to DrRacket to run the code. DrRacket will prompt you to revert the file if it was modified.
/) to get there quickly).
grades.txtfile in the “Summary” row on the handin server. You should plenty of grade indications to know when you’re not doing so well: catching this early and discussing it with us will make a “recovery” much easier.