How to Scheme for 6.034

We will add detail to this page as we learn from you what needs to be clarified. If you have any problems, please let us know, so we can update the page to cover them.

The Online Tutor

When you write scheme code and evaluate it within the online tutor system, it will be evaluated on the server that runs a slightly different scheme interpreter, called SCM. As a result, it may not necessarily include every function in the MIT Scheme documentation. But, both MIT Scheme and the on-line system implement the Scheme standard, which is documented here.

Choices

In general, you have two choices: you can run Scheme locally on your machine, or directly on Athena. If you choose the former option, we strongly encourage you to use the most recent version of Scheme. Older or alternate versions (such as scheme for 6.001) may be incompatible; for example, they might not preserve rationals (try (/ 1 3) ).

Running MIT Scheme (on PC's only)

If you have a PC, the current version of MIT Scheme is 7.7.1 for Windows*, Linux on x86, OS/2 and FreeBSD on x86. (There is no version for the Macintosh). MIT Scheme includes Edwin, a stripped-down version of Emacs, as you may remember from 6.001. Go to MIT Scheme and follow the instructions for installing it on your system.

You must also download onto your machine the homework files provided by us for each homework assignment. There are links to these files on the assignment page.

Running DrScheme

We are now supporting Dr. Scheme on an experimental basis. If you have a mac, you might want to try this. For instructions on how to use DrScheme with 6.034, please see these instructions on obtaining and installing DrScheme for 6.034.

Running Scheme on Athena

To run scheme on Linux-based Athena workstations, type the following:

add scheme
scheme -edwin -edit

This will start the Edwin editor in the most recent version of Scheme (better than the 6.001 version). Once in Edwin, you may want to use the (cd "newdir") command described in the bottom section to change your working directory.

We currently do not support running scheme on other types of Athena workstations, such as Sun workstations, SGIs, or other platforms, as the Scheme implementations on these platforms are obsolete or broken. You will likely encounter problems if you try to evaluate 6.034 code using MIT Scheme on these workstations.

Finding Documentation

MIT Scheme documentation is available on line (at the download site). We are not printing it because most people already have at least one copy of the basic documents or are happy to access what they need on line.

Documentation for DrScheme is available here: PLT-scheme documentation page.

The Scheme for the on-line system is not MIT Scheme, so it will not necessarily include every function in the MIT Scheme documentation. But, both MIT Scheme and the on-line system implement the Scheme standard, which is documented here.

Examples of Miscellanous Useful Scheme Stuff

Functions

(pp expression)

Pretty prints an expression.

(cd "/mit/6.034/ps1")

Changes the working directory.

(pwd)

Print the working directory.

(load "match.scm")

Loads and evaluates contents of a file (here, match.scm).

(trace function-name)

Shows the input arguments and output value when the function is called. Redefining the function, such as by loading a file that defines it, undoes the tracing.

(debug)

Shows you useful information when at an error breakpoint.

(load-option 'format)
Enables the use the format function. While you won't need to use this, some assignments make use of it.

You may find a more comfortable general-purpose display function to be:

(define disp (lambda args
   (letrec ((disp-in (lambda (arg) 
              (if (null? arg) 
                  'Done 
                  (begin 
                     (display (car arg)) 
                     (disp-in (cdr arg))))))) 
      (disp-in args))))

which will allow you to do things such as:

(define foo 42)  
(disp "The answer is " foo " nodes.") 

and get:

The answer is 42 nodes.

Under Windows, you may want to reduce the font size using the option in the menu of the upper-left system box.

Because Edwin is similar to Emacs, you may find the Athena On-line Help pages useful.

Key Bindings

There are a number of key combinations that you may want to be aware of, in case you missed them in 6.001. You can find these in the various documentation files mentioned above. Here is a brief summary (C- means hold down control; M- means hold down meta or alt):

C-x C-f : Open a file, or create a new one

C-x C-s : Save a file

C-x k : Kill (close) a buffer

C-x C-c : Exit Edwin


C-g : Abort a command

C-x C-e : Evaluate the previous expression

M-z : Evaluate the expression surrounding the cursor

M-o : Evaluate an entire buffer (careful!)

C-c C-c : Quit from an error level after a bad evaluation

M-p : Recall the last expression


C-space : Mark the current cursor position

C-w : Cut from current position to mark

M-w : Copy from current position to mark

C-y : Paste (yank)


C-x 2 : Split screen vertically

C-x 5 : Split screen horizontally

C-x 1 : Return to non-split screen


M-x : Enter a command by name (use tab to complete)