CSC 153 Grinnell College Spring, 2005
 
Computer Science Fundamentals
Laboratory Exercise
 

Getting Started

Goals

The following sections of this lab provide practice with material discussed in the reading for this laboratory exercise.

As noted in the reading, you may already be familiar with some of the mechanics given here, since you have already programmed in some language on some computer system. However, you should work through these steps completely (even if quickly) to be sure there are no surprises. When you get to the material in Scheme, be sure you understand each result before going on.


Logging In and Out

When logging into MathLAn, you will want the system to use the GNOME user interface for your account.

  1. You should follow these steps the first time you log in.


Mozilla Firefox

Once logged in, you should open the Mozilla Firefox browser.

Note that details for the following outline are given in the reading for this laboratory exercise.

  1. Open the Mozilla Foxfire browser by clicking on the Foxfire icon (the picture with a fox at the bottom panel of the screen).

  2. If this is your first time running Mozilla Foxfire on MathLAN, you may encounter two message boxes, asking your consent to the Firefox licensing agreeement and requesting permission to create some configuration files in your home directory. You should approve both of these requests by clicking on the appropriate response box.

  3. Initially, Foxfire should show this department's origin page:
         http://www.cs.grinnell.edu/origin.xhtml
    
    Examine the course listings on the left to find the home page for this course.

  4. Use the Bookmarks option at the top of the browser to Bookmark This Page for future reference.


The Terminal Window

  1. After logging in, open a terminal window by moving the mouse onto the small monitor icon on the bottom row of the front panel, and clicking with the left mouse button.

    Close the terminal window by typing <Ctrl/d> at the prompt.


Changing Your Password

  1. Unless you have done so recently, change your password by typing password in a terminal window and following the prompts that follow.


Running Scheme:

  1. Run Scheme by typing scheme (all in lower-case letters) in a terminal window. This will result in the following response:

    Chez Scheme Version 5.9i
    Copyright (c) 1998 Cadence Research Systems
    
    >
    

    where > is the prompt where you will type your programming instructions.

  2. Practice shutting down Scheme by pressing <Ctrl/d> at the Scheme prompt.

  3. Start Scheme again, and press <Ctrl/d> twice.
    What happens? Why?


Working within Scheme

Experiment with numbers in Scheme.

  1. Integers: At the Scheme prompt, type several integers, such as
        7
        -10
        3.1415926535
    
    In each case, note how Chez Scheme responds.

  2. Fractions: Determine what happens when you enter a fraction. For example, what value is returned when you enter:
        3/5
        -18/19
        10/34
    
    How many digits are printed in the answer for rational numbers?

  3. Enter several real or floating point numbers, such as
        3.1415926535
        10.00
        -1.414
        0.1
    

  4. Accuracy: Enter several numbers with many digits. How many digits are printed in the answer for integers? For reals?

  5. Numeric Procedures: In Scheme, all operation names are listed as the first component within the parentheses, so (f x) is typed to represent the functional value f(x). Observe what happens when you type the following operations into Scheme:
        (- 27 3)
        (/ 17 2)
        (/ 17 -2)
        (/ 17 2.0)
        (truncate (/ 17 4))
        (modulo 17 3)
        (sqrt 4)
        (sin 0.5)
        (sqrt -2)
        (+ (* 3 2) (/ 8 4))
    

    Do any of your results from these experience suggest other types of numbers that are available within Scheme (beyond integers, rational numbers, and floating-point numbers)? Explain briefly.

  6. Symbols: Consider the symbols TwoBeOrNot2Be and This-is-a-symbol. Describe what happens when you type one of the above symbols into Scheme.

  7. Give the symbol pi the value 3.141592 as follows:
         (define pi 3.141592)
    
    Now enter pi into Scheme and determine what happens.

  8. Check if work with symbols within Chez Scheme is case sensitive. What happens if you type Pi or PI.

  9. Check whether Scheme allows you to redefine the value of a symbol. For example, following the 1897 Indiana House, try to declare that the value of pi is three:
         (define pi 3)
    
    Now what happens if you type the symbol pi?

  10. Determine what happens if you make a typographical error. For example, try misspelling define or leaving out a left or right parentheses. In each case, make a note describing what happens.

  11. Binding: Consider the following sequence of definitions:
       (define a 4)
       (define b 5)
       (define c 1)
       (define discriminant 
             (- (* b b) (* 4 (* a c))))
       (define root1
             (/ (+ (- b) (sqrt discriminant))
                (* 2 a)))
       (define root2
             (/ (- (- b) (sqrt discriminant))
                (* 2 a)))
    
    Determine the values for a, b, c, discriminant, root1, and root2 .

  12. Continue the previous problem by changing the values of a, b, and c. Are the values of discriminant, root1 and root2 changed immediately, or do these symbols have their earlier values?


This document is available on the World Wide Web as

http://www.walker.cs.grinnell.edu/courses/153.sp05/labs/lab-getting-started.shtml

created December 29, 1996 by John David Stone
last revised January 22, 2005 by Henry M. Walker
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.