CSC 151.01, Class 25: Preconditions, Revisited
Overview
- Preliminaries
- Notes and news
- Upcoming work
- Extra credit
- Questions
- Quick reading summary
- Lab
News / Etc.
- New partners!
- Quizzes returned; current grade status coming tonight.
- There was enough confusion on quiz 5 that I will now drop the two lowest quiz grades. (That’s better than not counting it.)
- Note to the Narrator: If you are going to draw cartoons about my exams, make sure that you include one about sending email questions.
- Welcome to any visiting prospective students.
- Please introduce yourself.
- Please indicate what other schools you are considering.
- A lot of places
- Tulane, MIT, Rice, State School (none of these are like Grinnell)
- About ten schools
- East coast schools, like Hamilton
- Midwest, Seattle, Bay Area
- You may ask the students in this class a question.
- Is this class hard?
- Yes, but when you finally figure things out it’s fun. Plus Sam makes really bad jokes.
- Did you meet someone new in this class?
- Yes, whether or not that’s a good thing is questionable
- How many of you have declared a major?
- Some
- What’s something you’ve learned in this class? (Other than CS)
- I’ve learned there are cool people on the top of my head
- Don’t spend hours staring at your laptop screen making no progress. Ask for help! (Also don’t hit your head against the wall)
- A bit about art things, such as colors and color palettes
- Practice self gov
- Why Grinnell
- Get personalized attention
- Small enough that you’ll meet some people quickly
- One-on-one individualized attention
- We bribe you to come, even though Kington wants us to stop
- Not so distracting, not so expensive
- Events are free, including the concerts, the plays, the amazing basketball/hockey team.
- Inarticulate administrators
- You will have construction on campus for most of your time here. Check out the Facebook page for more details.
- People are happy (hah!) care about each other (Have you met Prof. Rebelsky?), and like it here (that’s why Kington thinks it’s imperative to increase the retention rate)
- We’re not Reed.
- How do you learn in this class?
- cricket noises
- Is this class hard?
Rotating reminders
- Ask questions via email! I’m always happy to (try to) answer questions via email. There is no need to apologize when sending me questions. If I take too long to answer, send another email (or even text, if it’s a reasonable hour).
Upcoming Work
- Exam 2 due TOMORROW NIGHT at 10:30 p.m.
- Epilogue due Wednesday night
- Lab writeup: Exercise 3
- Reading: Characters and strings
Extra credit (Academic/Artistic)
- CS Table, Tuesday at noon, Generating poetry
- Readings should be outside Curtsinger’s office
- CS Extras, Thursday at 4:15 pm, The CS curriculum
- Up to two of the events in the Rosenfield Technology and Human Rights symposium
Extra credit (Peer)
- Playboy of the Western World, this weekend (9th-12th).
- Ritalin Test Squad Friday the 10th.
- South Asia Tea Time Friday 4pm in JRC Cultural Suite
- G-Tones concert, March 12 with Opposed to Toy Trains (aka Con Brio), time tbd in Bucksbuam Rotunda
- Grinnell Singers, March 12 at 2pm
Extra credit (Misc)
- Tuesday 11:00 a.m. discussion about controversial speakers
Good things to do
Notes on quiz 5
Part 1
(define v #f)
(define w #t)
(define x 5)
(define y "123")
(define z 0)
(and x y)
(or v y z w)
(< z 4 x 5)
(or (< x z) x)
(not (or (< x z) x))
- What does
(or exp1 exp2 exp3)do? - Evaluates each expression in turn. If any are trueish it returns the first trueish one (and doesn’t evaluate any remaining expressions). In all of them are #f, we get back #f.
- What does
(and exp1 exp2 exp3)do? - Evaluates each expression in turn. If any are false, immediately returns false. If all are trueish, returns the value of the last one.
- What does
(not exp1)do? - Evaluates the expression. If the expression is #f, it returns #t. If the expression is #t or trueish, it returns #f.
(define v #f) (define w #t) (define x 5) (define y "123") (define z 0)
> (and x y) => (and 5 "123") => "123"
> (or v y z w) => (or #f "123" 0 #t) => "123"
> (< z 4 x 5) => (< 0 4 5 5) => #f
> (< 0 4 5 521321321) => #t
> (or (< x z) x) => (or (< 5 0) 5) => (or #f 5) => 5
> (not (or (< x z) x)) => (not (or (< 5 0) 5)) => (not 5) => #f
- What is trueish?
- Scheme is weird. It has three kinds of truth. There’s #f, which is false. There’s #t, which is true. There’s everything else, which is trueish.
Part 2
Create the list '(20 19 18 17 26 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1).
> '(list 20 19 18 17 26 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1)`.
> (iota 20) ; gives (0 1 2 3 ... 19)
> (reverse (iota 20)) ; (gives 19 18 17 ... 0)
> (map increment (reverse (iota 20))) ; gives what we want
> (reverse (map increment (iota 20))) ; gives what we want
; We need map to do something to each element in the list
> (map - (make-list 20 20) (iota 20)) ; gives the right answer, but builds an extra list
> (map (section - 20 <>) (iota 20))
Questions
- What does it look like when DrRacket corrupts our exam files?
- When you try to open the file, DrRacket says “Sorry, I can’t read that file.”
- Sometimes, Sam can help.
Quick reading review
Discuss with partner and be prepared to report back.
- What are preconditions?
- Expectations about the input or state of the system that must be met if the procedure is to work correctly.
- What normally happens if they are not met?
- We can do whatever we want.
- How do we verify preconditions so that the client gets an error
- message when the preconditions are not met?
- Use conditionals and then calling
errorwhen they are not met - What is husk-and-kernel programming?
- Iowa’s contribution to program design
Lab
Your writeup is Exercise 3.
Writeup
Write up exercise 3 from the lab verifying preconditions.
Send your solution to csc151-01-grader@grinnell.edu.
Title your email CSC 151.01 Writeup for Class 25 (YOUR FULL NAMES).