InstallingRacket
Home Assignments Martin Blog Sherman Blog Resources Project Discussion Group
Installing Racket
Download DrRacket from http://racket-lang.org. Any version from 5.x forward is fine.
Important: After launching the application, go into the Languages menu and select Use the language declared in the source. The text #lang racket
should appear in the untitled buffer.
Making gzip tar files for the autograder
You must be able to create .tar.gz
(gzipped Unix tar archive files) to upload your work to Bottlenose.
On Linux or Mac, gzip
and tar
are built into the shell and directions are given in the first assignment.
On Windows, you should download 7-ZIP and use it.
More about Racket
Don't worry; Racket is Scheme.
In the Scheme interpreter, you will use a development environment called DrRacket. The DrRacket main window has two panels. In the upper panel you edit your answer file (or whatever Scheme code you happen to be working on). The DrRacket documentation calls this panel the definitions window.
The lower panel is for interaction with the Scheme interpreter, and is called the interactions window. Please see the documentation for the Scheme programming environment at http://docs.racket-lang.org/reference/ for more.
Use the Execute button or the F5 key to load the contents of the definitions window into the Scheme interpreter. Executing will wipe out any previous contents in the interactions window. Use the interactions window for typing small tests, for finding the values of expressions, and for any text I/O (resulting from evaluating read, write, or display expressions).
DrRacket uses key bindings for editing commands similar to those used by the Emacs editor (just different enough to be annoying). You can also perform many editing tasks using the mouse and the menus.
To start Scheme in the lab on a Linux machine, type drscheme at the command line of a terminal window. You can download DrRacket for your own computer (Windows, Mac, or Unix) from the web site linked on the course web page.
Evaluating expressions
After you have learned something about editing in DrRacket, go to the interactions window (the lower panel in the DrRacket window) You can type Scheme expressions, and they should be evaluated and the result printed out.
Type in and evaluate (one by one) the expressions from Section 1 of this assignment to see how well you predicted what the system would print. If the system gives a response that you do not understand, try to figure out what the system is doing.
Observe that some of the examples printed above in Section 1 are indented and displayed over several lines for readability. An expression may be typed on a single line or on several lines; the Scheme interpreter ignores redundant spaces and carriage returns. It is to your advantage to format your work so that you (and others) can read it easily. It is also helpful in detecting errors introduced by incorrectly placed parentheses. For example the two expressions
(* 5 (- 2 (/ 4 2) (/ 8 3)))
(* 5 (- 2 (/ 4 2)) (/ 8 3))
look deceptively similar but have different values. Properly indented, however, the difference is obvious.
(* 5 (- 2 (/ 4 2) (/ 8 3)))
(* 5 (- 2 (/ 4 2)) (/ 8 3))
When you type Enter at the end of a line, DrRacket will automatically indent the next line as needed. You can also select a region, or the whole buffer, and hit Tab to auto-indent it.