CSC 151.01, Class 28: Higher-order procedures, revisited
Overview
- Preliminaries
- Notes and news
- Upcoming work
- Extra credit
- Questions
- Trees lab, continued
- Quick debrief
- Vectors lab
- Debrief (?)
Preliminaries
News / Etc.
- Continue partners!
- Quiz 9 returned. We’ll talk about it quickly.
- I finally got my grading software re-written. Expect email grades
later today. Feel free to send corrections.
- The math could be wrong.
- I could be missing grades (e.g. extra credit)
Upcoming work
- Exam 3
- Exam due TOMORROW via email
- Epilogue due Wednesday via email
- Cover sheet due in class Wednesday
- Lab writeup for class 27/Trees: Exercise 8. Due before class Wednesday.
- Lab writeup for class 28/HOP: Exercise 5. Due before class Wednesday.
- Reading for Wednesday
- Flash Cards due Wednesday at 5pm.
- Optional.
- Percent of eight flashcard assignments you complete (capped at 100).
Extra credit (Academic/Artistic)
- Mando Memorial Lecture, Tuesday at 4:15 p.m. in JRC 101
Extra credit (Peer)
- Drag show April 14
Extra credit (Recurring peer)
- Listen to KDIC Wednesdays at 6pm - Witty banter with other
personalities and/or co-host. Also Indian, Arabic, and Farsi music.
(Up to two units of extra credit.) - Peer editing with SS. Talk to SS about the details. Make your English Lit more literate.
Extra credit (Misc)
- Host one or more prospective students. (I think there’s one visit weekend left.)
Other good things
- Leah Lakshmi Piepzna-Samarashina talk tonight at 7:30 p.m. in Harris.
- Tom Jorling presentation 7:30 p.m. tonight in Noyce 2022
- Movie: Making a Killing: Guns, Greed and the NRA, Tuesday, 7pm
Questions
Should we do more than just run your test suite in the examples section?
I’d prefer that you either (a) add a test case or two or (b) run an extra example or two by hand.
You do, however, have to show the result of running
run-tests.
Can we convert lists to vectors in exam 3?
No.
Continue trees lab
Writeup: Exercise 8, number-tree-sum.
Start hop lab
How does apply differ from map?
mapapplies a procedure to each element of a list, creating a list of new values.applyapplies the procedure to all the elements en masse, creating on value of whatever type the procedure returns.
How does apply differ from reduce?
reducereduces a list to a single value by repeatedly applying it to neighboring pairs.(reduce + '(1 2 3 4))is approximately(+ (+ (+ 1 2) 3) 4)applydoes everything en masse.(apply + ‘(1 2 3 4))is(+ 1 2 3 4)`reduceneeds to have a binary procedure that returns the same type that it takes as input.- In contrast,
applycan return different types (and even take different types of inputs).- We can’t write
(reduce < '(1 2 3 4)). (Why not?) - We can write
(apply < '(1 2 3 4)). That computes(< 1 2 3 4).
- We can’t write
- We can use
applyin a variety of other situations, such as with ternary procedures.- We can’t write
(reduce substring '("grinnell" 0 4)). - We can write
(apply substring '("grinnell" 0 4)).
- We can’t write
What’s the writeup for class 28?
- Exercise 5. Solve with recursion.
Debrief on trees lab
Next class.
Writing number-tree-largest.
Debrief on hop lab
Next class.
Direct recursion is your friend!