EBoard 30: Data abstraction

Warning! You are being recorded (and transcribed).

Approximate overview

  • Quiz [15 min]
  • Administrative stuff [5 min]
  • Data Abstraction [10 min]
  • Questions [5 min]
  • Lab [40 min]
  • Turn in lab (maybe) [5 min]

Administrative stuff

  • There is no reading for Monday. Monday will be a bit of a “catch up” day.
  • Depending on how far we get on the lab, we may also finish the lab on Monday.
  • Don’t forget to submit the CHANGES.rkt file (summarizes your changes) when you want the graders to look at your redo.

Token opportunities

Academic/Scholarly

  • Tuesday, 2024-04-16, noon, some PDR CS Table (topic TBD).
  • Tuesday, 2024-04-16, 7pm, Science 3819 Mentor Session.
  • Thursday, 2024-04-18, 11am, JRC 101. Ruha Benjamin on “Viral Justice: How We Grow the World We Want”
  • Thursday, 2024-04-18, 4pm, ???. CS Poster Session, Part 2.
  • Thursday, 2024-04-18, 7pm, Science 3819 Mentor Session.

Cultural

  • Friday, 2024-04-12, 4:00-5:00pm, HSSC N1170 Middle of Everywhere. (Bengali)
  • Friday, 2024-04-12, 6:30-?:??pm, JRC 209. Shabbas Dinner.
  • Saturday, 2024-04-13, 1:00–5:00pm, Cleveland Beach. Holi! Wear white clothes (that you don’t mind getting stained). Color dyes. Water pistols, Photo booth.
  • Saturday, 2024-04-13, 7:00-9:00pm, Main Hall. Nepali New Year.
  • Saturday, 2024-04-13, 3:00–5:00pm, JRC 101. Vietnamese Desert.

Peer

Sam probably screwed this up. Check the calendar or pioneers.grinnell.edu.

  • Saturday, 2024-04-13, 9:00–noon, Tennis Courts. Men’s Tennis vs. Cornell (College).
  • Sunday, 2024-04-14, 2:00–5:00pm, Tennis Courts. Men’s Tennis vs. Cornell (College).
  • Sunday, 2024-04-14, Noon–3:00pm, Pioneer Park. Baseball vs. Knox.
  • Saturday, 2024-04-20, Noon–3:00pm, Pioneer Park. Baseball vs. Beloit.
  • Saturday, 2024-04-20, 2:30–5:00pm, Pioneer Park. Baseball vs. Beloit, revisited.
  • Sunday, 2024-04-21, 10:00am–1:00pm, Tennis Courts. Men’s Tennis vs. Coe.
  • Sunday, 2024-04-21, noon–3:00pm, Pioneer Park. Baseball vs. Beloit, revisited. The Sequel!
  • Sunday, 2024-04-21, 2pm–4:00pm, Sebring Lewis Hall. Grinnell Singers with a King Singer.

Wellness

  • Friday, 2024-04-12, 3:00–5:00pm, JRC Courtyard Get Nostalgic.
  • Tuesday, 2024-04-16, noon-1pm, BRAC P103. HIIT and Strength Fitness Class.
  • Tuesday, 2024-04-16, 12:15–12:50, Bucksbaum 131. Yoga in the Museum.
  • Tuesday, 2024-04-16, 4pm, BRAC P103 (Multipurpose Dance Studio): Yoga.

Misc

Other good things (no tokens)

  • Saturday, 2024-04-20, 1:00–3:00pm, . Softball vs. Ripon.
  • Saturday, 2024-04-20, 3:00–5:00pm, . Softball vs. Ripon, revisited.

Upcoming work

Friday PSA

  • Please be moderate in all that you do, even CS.
  • Consent is essential.

Data abstraction

Overview: What are key ideas in the reading?

  • You can represent the same data in different ways (hash tables, vectors, lists, strings, …).
  • We should write procedures that are somewhat independent of the representation (as much as possible).
  • However, we’ll need to agree upon (or design) a basic set of procedures that correspond to what we want to do with data?
    • Create a name.
    • Extract title, given, family, suffix.
  • We have to be careful about the assumptions we make. For example, not everyone has a family name. Try to be inclusive.
    • You don’t know.
  • Unfortunate: We sometimes have to make compromises, those may be biasing against some people. At minimum, we should acknowledge that.

Questions

How do we balance “not everyone has a last name” with “some people are too lazy to enter their last name”?

Names aren’t great identifiers. They are repeated.

We can set up systems that discourage people from leaving out data.

Self-check 1: Printing names (‡)

Write a procedure, (name->string name), that takes a name and converts it to the appropriate string. name->string should work no matter what representation we use, even if we use a representation we have not yet covered.

> (name->string qe2)
"Queen Elizabeth II"
> (name->string clay) 
"Roy Clay Sr"

A solution and a thought process.

;;; (name->string name) -> string?
;;;   name : name?
;;; Convert a name to a string, no matter how names are implemented.
(define name->string
  (lambda (name)
    ...))

I have

  • name-title (which returns string or #f),
  • name-given (always returns a string),
  • name-middle (which returns a string or #f),
  • name-family (which returns a string or #f), and
  • name-suffix (which returns a string or #f)
(define name->string
  (lambda (name)
    (string-append
     (if (name-title name)
         (string-append (name-title name) " ")
         "")
     (name-given name)
     (if (name-middle name)
         (string-append " " (name-middle name))
         "")
     (if (name-family name)
         (string-append " " (name-family name))
         "")
     (if (name-suffix name)
         (string-append " " (name-suffix name))
         ""))))

I should probably clean up the code a bit.

(define name->string
  (let ([helper (lambda (str-or-false) 
                  (if str-or-false 
                      (string-append " " str-or-false)
                      ""))])
    (lambda (name)
      (string-append
       (if (name-title name)
           (string-append (name-title name) " ")
           "")
       (name-given name)
       (helper (name-middle name))
       (helper (name-family name))
       (helper (name-suffix name))))))

One alternate. Make a list! Look up documentation.

(define name>string
  (lambda (name)
    (string-join (filter string?
                         (list (name-title name)
                               (name-given name)
                               (name-middle name)
                               (name-family name)
                               (name-suffix name)))
                 " ")))

Self-check 2: Yet another representation (‡)

Suppose we were planning to represent names as strings with the components separated by vertical bars. For example, "|Barack|Hussein|Obama|II" or "Queen|Elizabeth|||II". Sketch how you would write procedures like name-given and name-family that extract the various parts of the name. You might, for example, use string-split.

A solution and a thought process.

(define name-prefix
  (lambda (name)
    (list-ref (string-split name "|") 0)))

(define name-given
  (lambda (name)
    (list-ref (string-split name "|") 1)))

Questions

Administrative

Are we permitted to use a page of notes on quizzes?

Of course.

Dictionaries / Maps / Hash Tables

In (hash-ref hash key ""), what does the “” do?

If you give hash-ref three parameters, the last one is the “default”, which is returned if the key is not in the hash.

Registration

What does the “Do not click THIS button” do?

Attempts to register you for classes (it’s normally the register button), but all classes are marked as full, so it tells you to join the waiting lists and therefore makes you sad because the “Join Waiting List” feature does not yet work.

What are your opinions regarding our vendor?

Ellucian SelfService (or whatever Ellucian we are using) is not necessarily designed for schools like Grinnell nor registration processes like we try to use. Perhaps it is unsurprising that it does not work properly all the time.

I am frustrated that it yet again is adding stress to students’ lives.

MP7

Lab!