Held: Tuesday, 30 September 2014
Back to Outline 18 - Programming the GIMP Tools.
On to Outline 20 - Anonymous Procedures.
Summary
We begin to explore Scheme's conditional control structures,
particularly if
, when
, and cond
.
Related Pages
Overview
- The parts of an algorithm, revisited.
- Choosing between two options with
if
.
- Optional evaluation with
when
.
- Making multiple choices with
cond
.
- Comparing approaches.
Administrivia
- New Partners!
- I've been reflecting a bit on the "vocabulary" you need for our quizzes.
On one hand, I think you do much better if you memorize what the procedures
are and what they do. On the other, I know that such memorization can be
quite difficult. Hence, as an experiment on this Friday's quiz, I will
allow you to bring one page of notes to the quiz. (8.5x11 or A4,
double sided, hand written)
- Office hours (modified due to meetings):
- Wednesday 8:00-9:45
- Thursday 8:00-9:45, 2:30-3:15
- Friday 1:45-3:15 (also Walking hours 1:15-1:45)
- Review sessions Wednesday and Thursday night at 8 p.m.
- Let me know by 5pm today if you want to work alone on the next HW.
- I've had a student indicate that they will not be able to start HW 5
until late Sunday afternoon and that they want partners for the HW.
- To provide you with incentive to take your own notes on each topic we
cover: If you send me a summary of what you think are the important
takeaways from any reading/lab combination, I will comment on your summary.
Upcoming Work
Fun Things with no Extra Credit Value
- GHS Homecoming Parade Thursday at 5:30 pm. (Small town Iowa homecoming
is a fascinating experience.)
- Friends of Drake Library Book Sale, Friday night and Saturday. At
about 11 am on Saturday, you can get a box of books for a buck.
(Earlier, it's 50 cents for paperbacks and $1 for hardcovers.)
Extra Credit Opportunities
Academic
- Campus Town Hall Tuesday at noon or 7:30 p.m.
- CS extras next Thursday: Alumni
- CS table Friday: Serendipity and Computing (with Grinnell's Artist
in Residence)
- Grinnell Prize events the following week (particularly events related
to the prize winners whose project involves Web tools)
Peer Support
- Anna Christie, Oct. 9-12 (SB plays Marthy)
- Football (???)
- Men's Tennis (???)
- Women's Tennis (???)
- Swimming (???)
- Evan's radio show 5pm Friday nights on KDIC
- Donna's radio show Sunday midnight on KDIC
Miscellaneous
The Parts of an Algorithm
Remember those? We did them early on in the semester.
- You need to have some basic operations.
- You need to be able to sequence your operations, explicitly
or implicitly.
- It's nice if you can name values.
- You need to be able to write subroutines (aka procedures) that
parameterize a piece of code.
- You need to be able to repeat instructions.
- You need to be able to choose between options.
How many of these do we know? Almost all of them.
Choosing Between Options with if
- The first mechanism for choice.
- Form
(if TEST CONSEQUENT ALTERNATE)
- Meaning
- Evalute the TEST.
- If the TEST is not false ("holds"), evaluate and use the value
of the CONSEQUENT.
- If the TEST is false, evaluate and use the value of the ALTERNATE.
- Note:
- You only get one consequent
- You only get one alternate
Optional Evaluation with when
- Useful only when you're sequencing operations.
- Form
(when TEST CONSEQUENT_1 CONSEQUENT_2 ... CONSEQUENT_n)
- Meaning
- Evaluate the TEST.
- If the consequent is not false ("holds"), evaluate each
of the consequents in turn. Use the value of the last
consequent.
- If the consequent is false, do nothing. Return nothing.
- Note:
- You get as many consequents as you want.
Choosing Between Multiple Options with cond
Comparing Approaches
- Returns a value:
cond
and if
.
- Lets you have multiple consequents:
when
and cond
.
- Let's you choose between options
cond
and if
.