Skip to main content

CSC 151.01, Class 33: Association lists

Overview

  • Preliminaries
    • Notes and news
    • Upcoming work
    • Extra credit
    • Questions
    • Mentor evaluations
  • Lab
  • Debrief

News / Etc.

Upcoming Work

Extra credit (Academic/Artistic)

  • Convocation Thursday at 11 a.m. in JRC 101. “Work’s Provocative Future: Which Graduates Will Thrive?”

Extra credit (Peer)

  • Pub-free quiz at Bob’s. 9pm (I think). Math-Stats focus.
  • “The First Time I Walked on the Moon”. Four, count ‘em, four performances. Thursday at 7:30, Friday at 7:30, Saturday at 7:30, Sunday at 2:00.
  • Orchestra, Saturday at 2pm

Extra credit (Misc)

Other good things

  • Fresh Flutes Thursday
  • Voice recitals Friday at 4:15 (Henderson) and 7:00 (Manuel)
  • Women’s Basketball vs. Emmaus TONIGHT at 5:00 p.m.
  • Men’s Basketball vs. Emmaus TONIGHT at 7:00 p.m.
  • Swimming and Diving Saturday at 1:00 p.m.

Questions

Mentor Evaluations

  • Think about them as a group.
  • Our goal is to improve the program.
  • Aren’t forms fun?

Lab

Writeup: 4b and 4c.

When you write multi-assoc (or assoc-all or multi-assoc-2nd), think about the base case. You are returning a list of matching elements.
Hence, if there are no matches, you should return …?

> (multi-assoc "Sky Rebel" cartoon-sidekicks)
'()
How do you pronounce “assoc”?
Sometimes I say “a sock”, with a short o
Sometimes I say “a sosh”, with a long o (or like the “soc” in “sociology”)
But I also pronounce “ghoti” as “fish”

More Announcements

Whoops. Forgot these.

  • Reminder: Tomorrow’s convo looks to be cool. You should go.
  • Looking ahead: Angela Willig is running what looks to be a really awesome role playing scenario the Tuesday after Turkey break.
  • Quiz Friday: Algorithm analysis, association lists, maybe more trees
  • Review sessions: Tonight at 8pm, Tomorrow at 7pm and 8pm.

Debrief

How many of you wrote assoc-all (multi-assoc).

(define assoc-all
  (lambda (lst val)
    (let kernel ([so-far null]
                 [remaining lst])
      (cond
        [(null? remaining)
         (reverse so-far)]
        [(equal? val (caar remaining))
         (kernel (cons (car remaining) so-far)
                 (cdr remaining))]
        [else
         (kernel so-far
                 (cdr remaining))]))))

How I would have written assoc-all.

(define assoc-all
  (lambda (lst val)
    (cond
      [(null? lst)
       null]
      [(equal? val (caar lst))
       (cons (car lst) (assoc-all (cdr lst)))]
      [else
       (assoc-all (cdr lst))])))