Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Outside of lab, don't forget to get a homework partner, if you haven't already. If you're having trouble getting a partner, try using the sign up sheet. Partners are encouraged, but not required, to attend the same lab section.

...

DrScheme Basics

...

  1. Open a terminal.

...

  1. Make a new folder (directory) called Comp211, for this course. The command is for making a new folder on Linux is mkdir.

...

  1. Make a sub-folder in Comp211 called Labs.

...

  1. Make a sub-folder in Labs called Lab01. Save all your Lab01 work to this folder. For submitting homeworks, see the Owlspace page for Comp 211.

...

  1. Start DrScheme by typing the command drscheme.
    #If this is the first time you've run DrScheme, it will ask you your preferred language, and the Scheme language level; the latter should be "Beginning Student with List Abbreviations". This language level provides the expected set of primitive operations and enables DrScheme to reject "legal" Scheme constructions that are not part of our introductory dialect.

The DrScheme window is divided into two halves. The lower half, or interaction window, is the Scheme "calculator". The top half, or definition window is just a text editor which is smart about indenting Scheme, and such. The execute button sends the contents of the definition window down to the interaction window, where they are actually evaluated.

...

Simple example of using DrScheme

...

  1. Type (or copy/paste) the following expressions into the interactions window
    Code Block
    
    (+ 2 7)
    
    Code Block
    
    (* (+ 2 7) 3)
    

...

  1. Type (or copy/paste) the following blocks of code into the definition window, including:
    Code Block
    
    ;; owe: nat -> num
    ;; Returns how much money you owe for eating the given number of
    ;; slices of pizza.
    ;;
    (define (owe slices)
       (* (/ 12 8) slices))
    
    Observe that DrScheme helps you with the indentation if you use the Return key in appropriate places. It also "bounces" the cursor to visually match the closing parenthesis with the corresponding opening parenthesis.

...

  1. Use the definition of owe by typing in the interaction window some Scheme expressions using those definitions, e.g.,
    Code Block
    
    (owe 5)
    
    (owe 7)
    

...

  1. We included comments before each function definition, explaining what it is supposed to do. DrScheme ignores the comments, but you, your grader, your boss, etc., can read them. Soon, we'll provide more guidance on what to say in your comments.
    Code Block
    
    ; One form of comments is anything following a semicolon
    ; up to the end of the line.
    ;; However, you'll often see two semicolons starting a comment.
                
    #|
      Another form of comments is anything between these
      two matching markers.
    |#
    
    You can also go to the Special menu, choose Insert comment box. You are welcome to do this, but one caveat: if DrScheme saves a file which includes a fancy comment box, the file will not be saved in plain-text format. (This is only an issue if you want to open or print the file with a different program later.)

...

  1. Edit your definitions or comments some. You can use the mouse, the arrow keys, backspace, and standard keyboard shortcuts to move the cursor around. Also, the PC, Mac, and Unix versions of DrScheme each use their respective standard keyboard shortcuts. (You can look in the Edit menu under Keybindings for the complete list.)

...

  1. Load the definitions into the interaction window by clicking on the Run button. If DrScheme detects any syntactic errors, it will give you an error message in the interactions window and highlight the error in the definitions window.
    #Save your work in your Comp211\Labs\Lab01 directory. Be sure to use a filename that has a .ss extension. You don't need to turn in your lab work. In fact, you don't have to save it, but we recommend it so that you can look at it again.

...

  1. Finally, intentionally introduce an error or, what you think will be an error, press Run, and see what error message is given. We'll go around the room to see what different error messages people get. Do the error messages tend to make sense?

DrScheme has lots of other features, including a complete manual. We'll explore more of DrScheme in later labs, and we encourage you to explore, but there's no need to learn all its features. Read the DrScheme Tips and Traps page for helpful information on common mistakes, error messages, etc.

...