DrRacket Hints and Tips

TL;DR

Download DrRacket

You can download DrRacket from the official Racket website: https://racket-lang.org/download/. Make sure to choose the version that is compatible with your operating system, Windows, Mac, or Linux.

When You Open A File

DrRacket needs to know which language you want to use. To make your life easier, ignore the Language menu at the top of the window. If you already chose a language using the menu, you can change it by going to LanguageChoose Language and then clicking the top radio button, which says The Racket Language.

Once you’ve done that, make sure you add this line to the top of all your files: #lang htdp/bsl

This stands for “How To Design Programs / Beginning Student Language”.

If you want to use images, you will also need to add this line at the top: (require 2htdp/image)

If you want to do animations or interactive world programs, you will also need to add this line at the top:

(require 2htdp/universe)

If you ever get an error saying that something is not defined, check those three lines and check that the Language is set to The Racket Language. Also, ask a neighbor or me for help.

Definitions and Interactions

The top part of the screen is called the Definitions area. This is where you write your code. The bottom part of the screen is called the Interactions area. This is where you can try out stuff to see what happens.

To save the Definitions area, click on the floppy disk icon, or choose FileSave. You can also use the keyboard shortcut Ctrl+S (or ⌘+S on a Mac). You’ll need to type in a file name. Put the extension .rkt after the name to let the operating system know that this is a Racket file. Choose which folder to save your file into (Desktop works well, usually), and click the Save button.

I recommend saving all your files in a folder called apcsp or something like that, maybe with subfolders for files that go together.

To run your code, click on the green Run button at the top of the window. This will execute the code in the Definitions area and show you any output or errors in the Interactions area. It will also erase everything in the Interactions area. Don’t panic, however. Hitting the Esc key, then the P key will pull up the previous thing you typed in the Interactions area, and you can keep hitting Esc then P to go back through your history.