Skip to main content

Class 47: Association Lists

Held:

We consider *association lists, a simple, but useful, technique for organizing tables of information.*

Preliminaries

Overview

  • Storing information in tables
  • Representing table entries as lists
  • Representing tables as lists
  • Association lists - Schemes simple trable representation
  • Implementing association list procedures

Updates

News / Etc.

  • Keep your partners.
  • I should get proposal reviews out by late tonight.
  • I encourage you to sign up for CSC 161!
  • I apologize for being so far behind on grading.

Upcoming Work

  • Lab writeup: 4b
  • NO Reading for Friday
  • Quiz Friday.
    • Files
    • Algorithm analysis
    • A bit more on HOP
  • Projects due next Tuesday.
  • Exam 4 distirbuted next Wednesday.

Extra credit (Academic/Artistic)

  • CS Extras Thursday, 4:15pm: Project Gadfly
  • CS Extras, Thursday, May 4, 4:15 p.m.: Inclusion in CS. Please attend.
  • The Harold W. ’38 and Jean Ryan ’38 Squire Lectureship in Physics. May 2nd, 7:00 p.m., ARH 302. Astrophysicist Kartik Sheth (Grinnell class of 1993) will present From Mumbai to Grinnell to NASA HQ - Adventures in Time and Space

Extra credit (Peer)

  • AAA hosts Kit Yan performing Queer Heartache, Wednesday, Harris, 7pm.
  • LiNK Fundraiser: They are selling kimbab from 1-4pm ($2 vegan, $3 meat or seafood, $4 everything) to support North Korean refugees in China resettle in South Korea and the US.
  • Dance Ensemble show, Staying with the Trouble. Tickets are available in Bucksbaum box office for Thu, Fri, Sat at 7:30 and Sunday at 2:00.
  • Drill Team Show, May 5, at Triple V stables. The other side of the golf course. Free rides (cars, not pony) to the event!
  • Next home baseball game: May 7 (Senior Day)

Extra credit (Misc)

  • Make Your Mark on Phase 1!, Tuesday, May 2, 10 a.m., Near the Commencement Stage. (Light refreshments provided.) Leave a hand-print on the construction wall (which will become a Commencement backdrop!) to celebrate the Class of 2017. You can also make chopsticks from wood harvested at the construction site and get your photo taken at the construction-themed photo booth.
  • May 4 town hall on belonging. 11am, May 4, JRC 101

Other good things to do

  • Dag Field Day, Saturday, April 29, noon-5pm, in the Club Athletic Field.
    • Near the Softball diamond.
  • Raging Cow Atlatl event, Saturday, Club Athletic Field, 9:00 a.m.
  • Titular head (? whether or not it’s a good thing to do)
  • HvZ (also ? whether or not it’s a good thing to do)

Simple Database Problems

  • Databases are among the most common applications of computers.
    • After all, there’s a reason that Larry Ellison is nearly as rich as Bill Gates.
  • A database is a mechanism for storing data so that you can easily access the data you need.
  • One simple database activity is looking up values by keys.
  • Databases that provide only that activity are called dictionaries.

Association Lists

  • In Scheme, dictionaries are typically implemented with a data structure known as the association list.
  • An association list is a list of elements each of which has a key as its car.
  • You can use the (assoc *key* *list*) procedure to look up values by key.

Searching in Association Lists

  • Suppose Scheme didn’t include assoc. How would you write it? Probably recursively.
  • If the list is empty, it does not contain the value.
  • If the key of the first element in the list is the key we’re looking for, return the corresponding value.
  • Otherwise, look in the rest of the list.
  • This technique is called sequential search.

Variants of Association Lists

  • Given that we can write our own assoc procedure, we can easily implement a number of interesting variants of association lists.
  • For example, if the same key appears multiple times in the association list, we might return all matching values (rather than the first matching value).
  • Similarly, instead of searching by key, we might search by predicate.

Lab