Skip to main content

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

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?

  • map applies a procedure to each element of a list, creating a list of new values.
  • apply applies the procedure to all the elements en masse, creating on value of whatever type the procedure returns.

How does apply differ from reduce?

  • reduce reduces a list to a single value by repeatedly applying it to neighboring pairs. (reduce + '(1 2 3 4)) is approximately (+ (+ (+ 1 2) 3) 4)
  • apply does everything en masse. (apply + ‘(1 2 3 4)) is (+ 1 2 3 4)`
  • reduce needs to have a binary procedure that returns the same type that it takes as input.
  • In contrast, apply can 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 use apply in 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)).

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!