PVD 2002:
Some teachers thought it would be nice to have all the teachers
introduce themselves. SK finds this the kind of thing those other
workshops would do, and prefers instead to get started with lecture.
Figure out when you want to do this (suggestion below).
[Shriram's lecture]
We all know that every workshop should begin with a brief history
lesson. So: What's the oldest computer? Get them to say,
hopefully, ENIAC, Zuse, Babbage, abacus ... write down these names
and approximate dates, in chronological order. Let them muse some
more. Then pull out pea pods. Peas are computers that produce
new peas according to some computation. What program do they run?
(Put up dominant/recessive table from genetics.) What's the
computation? (The process of producing a new generations of peas.)
Computation is fundamental, and underlies many areas outside of CS.
In this problem, dominant/recessive is domain knowledge. What role
does CS have? CS is about information -- how to represent
information about domain-specific computations, how to write
computations as programs. If you want to mate one pair of peas,
call a biologist. If you want to simulate mating a thousand,
million, billion of them, call us.
How many people in college took "telescope science"? Ah, they had
astronomy. Or "microscope science"? Okay, biology. So what is
"computer science"? The Europeans have this right: they use terms
like "informatik", "informatique" and "datamation".
Welcome to TeachScheme!.
Then a bunch of admin points:
- introduce course staff
- introduce yourself
- have teachers introduce themselves
- you are here as students, not teachers
- save all pedagogy questions for Thursday session
-------------------------------------------------------------------
Time to learn programming with Scheme and see how simple it is:
What's the simplest Scheme program? 3. No public static void main.
This is a program that computes the value 3. [SK: Don't use "0"
instead. It looks too much like a special case.]
Expression Scheme
4 + 3 (+ 4 3)
3 + 6 * 2 (+ (* 6 2) 3)
5 - 2 teachers do these
5 * 4 - 10
6 * 4 + 12 * -2
Show evaluation, reductions
Cost of share of pizza, assuming pizza has 8 slices and you eat 3
- if pie costs $12.00 : (* (/ 12 8) 3)
- if pie costs $16.80 : (* (/ 16.80 8) 3)
Sometimes, want essentially same computation but with different
data. Name the rule for computing the answer.
;; share-cost : number -> number
;; consumes price of pizza, determines cost of 3 slices
(define (share-cost price)
(* (/ price 8) 3))
Evaluate/test
(share-cost 12) = 4.5
(share-cost 16.80) = 6.30
;; tip : number -> number
;; adds 15% tip to a price
(define (tip bill)
(* bill 1.15))
-------------------------------------------------------------------
THE BASIC RECIPE (p21): specify, make examples, define, test
[Kathi: remind them to write short, concise, pithy purpose stmts]
-------------------------------------------------------------------
THE PRINCIPLE: compose functions
;; share-with-tip : number -> number
;; consumes price of pizza, determines cost of 3 slices plus tip
(define (share-with-tip price)
(tip (share-cost price)))
|
LAB |