EBoard 27: Data abstraction

This class will be recorded! Its use is limited to members of the class. Please do not share with others.

Approximate overview

  • Administrative stuff [~10 min]
  • About MP6 [~10 min]
  • Q&A [~10 min]
  • Lab [~60 min]

Administrative stuff

Notes and News

  • Happy Tuesday! I hope your week is off to a good start!
  • I’ve been asked to attend a board meeting of the Richard Tapia Celebration of Diversity in Computing from 2:30-4:00 on Wednesday. Wednesday’s class will start with lab. I’ll assume that the mentors will be able to have things work.
  • I’ve been asked to attend a seminar on diversity in computing on Friday starting at 4pm. I’ll assume that the mentors will be able to make things work.
  • (No, it’s not that I don’t love you. But I have a life beyond our class.)
  • I only got 18 mini-project 5’s. That’s a bit worrisome. Some of you talked to me about extensions, but not all of you.
  • In helping people, I see that some of you are ignoring a few of the key practices we’ve tried to instill.
    • Decompose! It’s easier to figure out issues when you decompose.
    • Document, then write tests, then implement.
    • When things go wrong, think about simple cases.
    • Trust the magic recursion fairy, who says: “When writing a recursive procedure, assume that you’ve successfully written it, but that it only works for smaller inputs.”
  • Note: When I’m helping you on teams, I may be cycling between multiple students or multiple tasks. Feel free to tag me if you find that I’m not coming back to a conversation quickly enough.

Upcoming activities and other token-earning things

Events

  • Visit Grinnell Art Museum, maybe get an art pack https://www.grinnell.edu/campus-life/arts-culture/museum.
  • Mentor Session, Wednesday, 7pm. Prepare for the SoLA.
  • Thursday, CS Extras at 5pm (ReactAMole and Grapenut)
    • You can make molecules compute!
    • You can write programs through examples!
    • See Announcements for more info.
  • Monday, CS Table at noon

Upcoming work

I’m not sure if all of these links are correct. Let me know if any are not.

Some notes on MP6

Sam is almost on time.

Q&A

Questions from the reading

How does the hash-table version of name work?

(define name
  (lambda (prefix given middle family suffix)
    (let ([n (make-hash)])
      (when prefix
        (hash-set! n 'prefix prefix))
      (hash-set! n 'given given)
      (when middle
        (hash-set! n 'middle middle))
      (when family
        (hash-set! n 'family family))
      (when suffix
        (hash-set! n 'suffix suffix))
      n)))
  • (when test E1) is a shorthand for (cond [test E1]).
  • That is, it runs the test, if the test holds, it evaluate the expression and then returns the value of the exprssion.
  • If the test doesn’t hold, it’s like the “no else in a cond” situation; you get no value back.
  • When the body of a procedure has multiple expressions, Racket evaluates each in turn, and returns the value of the last.
> (define sam
    (lambda (n)
      (+ 1 n)
      (- n 1)
      (sqr n)))
> (sam 4)

Hypotheses

  • 2 [+1] (Note, this is sqrt)
  • 16 [+1]
  • 5 3 16 [+1]

When will you post redos?

Soon!

What are higher-order procedures?

Procedures that take other procedures as parameters. map.

Procedures that return other procedures as values. section or o.

If Racket ignores the values of all but the last expression in the body of a procedure, why have multiple expressions?

Some of them might have side effects, like vector-set! or hash-set!

So we can sequence side-effecting procedures.

Lab

Ah, the possibilities are endless.