=====
CS 111 - Week 4 Lecture 2 - 2025-09-18
=====
=====
TODAY WE WILL:
=====
* announcements
* cond expression review
* another cond example: dropping penguins!
* interval data, enumeration data
* example involving enumeration-style data: next-sound
* prep for next class
=====
* Should be working on Homework 3!
* submitting early and often!
* remember to attempt the Canvas short-answer questions
and at least some of Problems 4-onward by 11:59 pm on
Friday, September 19
=====
* Math Club will meet every Tuesday (planned)
at 6:00 pm in BSS 308
=====
INTERVALS and ENUMERATIONS
interval data and enumeration data
=====
* these both happen to be kinds of data where
branching is useful!
* interval - from HtDP/2nd ed - section 4.4:
"An interval is a description of a class of (real or rational or integer)
numbers via boundaries"
* these boundaries tend to define a finite number of categories,
but each category MIGHT contain many things!
* do you see that, for interval-style data,
it will often be useful to have a cond expression
with a branch for each of the intervals?
* you might be able to refactor it to have less,
but this is a good starting point;
* and: CS 111 class style:
you should have at least one test per interval,
PLUS at least one ADDITIONAL test per BOUNDARY between intervals
* functions banana-report, bad-star-size?, and draw-penguin-scene
are functions involving intervals
* enumeration - a type of data that is a relatively small number
of discrete, specific cases --
* a traffic light's colors of red, or yellow, or green
* 4 arrow keys of up, down, left, right
* etc.
* for enumeration-style data,
it will often be useful to have a branch for each of the
specific cases
* you might be able to refactor it to have less,
but this is a good starting point;
* and: CS 111 class style:
you should have a test for each of the specific cases,
and IF your function purpose statement specifies what to
do for a "bad" value, also include a test for that
* function next-sound, in today's in-class examples, is a
function involving an enumeration