## Tutorial 1: Introduction (September 12-14, 2007)- Preliminaries
- Welcome to CS 135 Tutorials!
- Web page, labs, consulting hours
- Tools
- DrScheme
- Open DrScheme
- Go to
**Languages**⇒**Choose Language**and select the language "Beginning Student" under "How to Design Programs". - The following code defines a constant
`speed-of-light` and a function`meters->lightyears` which converts a distance in meters to light years (approximately).(define speed-of-light 299792458) ;in m/s (define (meters->lightyears dist) (/ dist (* speed-of-light (* 60 60 24 365.3524)))) Copy and paste the preceding code into the *Definitions Window*in DrScheme. - Save the Definitions as
`t1.scm` . - Now compute the height of one of your IAs in light years by typing the line
(meters->lightyears 1.85) into the*Interactions Window*. - Odyssey
- Simple Functions in Scheme
- Scheme notation vs. Mathematical notation Convert the following functions from Scheme notation into standard mathematical function notation:
`(define (f x) (- (* 5 x) 4))` ⇒`f`(`x`) = ???`(define (g x) (- (/ (* (+ x 2) (- x 3)) 5) x))` ⇒`g`(`x`) = ???`f`(`x`) = (`x`+5)/(8`x`-9)⇒???`g`(`x`,`y`) = (`x``y`-7)(`x`+`y`) - (3`x`+ 5`y`- 12)⇒???- Function Evaluation Evaluate each of the following Scheme statements
`(- (* 4 5) (/ 6 3))` `(/ (+ 2 (- 5 2) (* 3 3)) (/ (- (* 5 5) 4) 3))` (define (f x) (* x (+ x 1))) (+ (f 1) (/ (f 2) 3)) (define (f x) (- x 1)) (define (g x) (* x (f (/ x 3)) 2)) (/ (g (g 6)) 2) - Reminders
- Assignment 0 due Sept. 17 (Monday)
- Assignment 1 due Sept. 20 (Thursday)
- Come back to tutorial next week.
DrScheme is an IDE (Integrated Development Environment) and interpreter for the Scheme programming language. Information on downloading and installing DrScheme can be found at http://www.drscheme.org.
With DrScheme installed on your system (or using a computer in one of the labs), try the following: Your programming assignments for CS 135 will be submitted electronically. The details of how to do this (and much more useful information) can be found in the Style Guide for Assignments. The easiest method is probably to use Odyssey, an online graphical interface to your UNIX account at https://www.student.cs.uwaterloo.ca/odyssey/. You will get practice submitting files in Assignment 0. Always be careful about what folders you put your solution files in and what you call your files, especially if you use Odyssey. Don't wait until the last moment to submit! by hand. Then use DrScheme to check your work. |

This file generated Monday, December 17th, 2007 using PLT Scheme and WebIt!