Racket Tutorial
Racket Tutorial
Racket Tutorial
Copyright c 2010 CSIL Maclab, University of Chicago
Table of Contents
1 2 3 4 Starting Dr. Racket and Picking a Language ................................................. 1 Using Dr. Racket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Saving and Printing Your Work . . . . . . . . . . . . . . . 5 Frequently Asked Questions . . . . . . . . . . . . . . . . . . . 6
It will take a while to actually open. When it does, you should see this:
Picking a Language
The first time you start Dr. Racket, you have to pick a language with the Language Chooser in the lower left.
The rest of this tutorial will use the language How to Design Programs: Advanced Student. Select it in the menu, then press OK.
After youve picked your language, you need to press the Run Button to load it. The Maclab deletes all personal data from our machines overnight, so when you come in again tomorrow youll have to pick your language again.
Dr. Rackets interface has two windowsthe Definitions Window and the Interactions Window (also called a REPL for Read-Eval-Print Loop). The Definitions Window is where you type your program; everything in there will be executed when you press the Run Button. The Interactions Window is an interactive prompt; if you type a Racket expression there and press enter, the expression will be evaluated and its value printed below the prompt. If youve run your program, any functions or variables youve defined will be available for use in the Interactions Window.
For instance, lets say we write the follow simple program to find out what 101 squared is: (define (square x) (* x x)) (square 101) We enter this into the Definitions Window and press the Run Button. The result of our program is outputted at the top of the Interactions Window.
If were then curious what 102 squared is, we can simply type (square 102) into the Interactions Window to find out:
An actual introduction to the Racket programming language is beyond the scope of this text. A quick introduction may be found at http://docs.racket-lang.org/quick/.
Your file name will end with an extension of .rkt by default. The default save destination is your Documents folder. Double clicking a .rkt file will open it in Racket by default.