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.

Warning

Most of what is in this document concerns MIT Scheme, which is what you will probably run on your machine or on Athena. 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.

Choices

There are about a million ways to do everything you might want to do. In particular, if you remember how to hack with Scheme from 6.001, most of what worked for you then should work for you in 6.034, and you need not read these notes with great care. However, be careful about using the 6.001 Scheme for 6.034. It has several differences from the standard version, such as not preserving rationals (try (/ 1 3) ). We strongly encourage you to use the most recent version of Scheme. This will mean that we will be able to reproduce any problems you experience.

In general, you have two choices: you can run Scheme on your PC or Linux box, if you have one, or you can run Scheme on Athena. Current thinking is that you are better off running Scheme on your own machine (f you have an Intel-X86 based machine). That's what we do.

Running Scheme on your machine

The current version of MIT Scheme is 7.7.1 for Windows*, Linux, OS/2 and FreeBSD. (There is no version for the Macintosh, though there is a free X server which may help you to work remotely.) 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 Scheme on Athena

To run scheme on Linux-based Athena workstations, type the following (which starts a Scheme with a large workspace):

add scheme
scheme-7.7.1 -heap 5000 -stack 500 -edwin -edit

This will start the Edwin editor in the most recent version of Scheme (better than the 6.001 version). . If you have any problems, you can also try 6.001 Scheme:

add 6.001
6001-scheme -heap 5000 -stack 500

Once in Edwin, you may want to use the (cd "newdir") command described in the bottom section to change your working directory.

If you are using a Linux or FreeBSD/NetBSD machine, you should be fine. The current version of MIT Scheme is also 7.7.1 for those platforms. (Note that if you would like, you can download a copy of MIT Scheme from MIT Scheme and follow the install procedures included to use a local version instead of the Athena version).

The Solaris and SGI machines have a version of Scheme installed. But, we will not be testing on these at all, though, so use them at your own risk. If for some reason this is your only option, ask a TA to tell you about SCM.

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.

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)