|CSC 153||Grinnell College||Spring, 2005|
|Computer Science Fundamentals|
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.
When logging into MathLAn, you will want the system to use the GNOME user interface for your account.
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.
http://www.cs.grinnell.edu/origin.xhtmlExamine the course listings on the left to find the home page for this course.
Close the terminal window by typing <Ctrl/d> at the prompt.
Unless you have done so recently, change your password by typing password in a terminal window and following the prompts that follow.
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.
Practice shutting down Scheme by pressing <Ctrl/d> at the Scheme prompt.
Start Scheme again, and press <Ctrl/d> twice.
What happens? Why?
Experiment with numbers in Scheme.
7 -10 3.1415926535In each case, note how Chez Scheme responds.
3/5 -18/19 10/34How many digits are printed in the answer for rational numbers?
3.1415926535 10.00 -1.414 0.1
(- 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.
(define pi 3.141592)Now enter pi into Scheme and determine what happens.
(define pi 3)Now what happens if you type the symbol pi?
(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 .
This document is available on the World Wide Web as
created December 29, 1996 by John David Stone
last revised January 22, 2005 by Henry M. Walker
|For more information, please contact Henry M. Walker at email@example.com.|