Skip to main content

CSC 151.01, Class 10: Reading lists and tables from files

Overview

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

News / Etc.

  • If you are a second-year student, please get one of the short survey forms from the mentors.
  • Please make sure to return your computer cards to the jar.
  • Answer key for homework 3 distributed last night.
  • Code of conduct to be distributed electronically. We’ll discuss on Monday.
  • I do not yet have my grading system up and running. When I do, I will distribute grades. Until then, I cannot.
  • If you ask me a face-to-face question outside of office hours, you may find that I am abrupt. I apologize. But I am often heading off to a meeting or class or preparing for one of those meetings or classes.
    • Email generally works well. Put HELP or QUESTION in the title.
    • If I haven’t responded within 24 hours, email again.
  • I’ve added office hours on Monday for folks with exam questions.

Upcoming Work

Extra credit (Academic/Artistic)

  • CS Table, Tuesday: (H)Activism

Extra credit (Peer)

  • Men’s Soccer vs. Buena Vista, Sept. 17 at 2:00 p.m.
  • Elephantitis, this weekend, Grinnell High School and Grinnell Middle School. (Ultimate (flying disc) tournament)

Extra Credit (Misc)

None at the moment.

Other Good Things

Friday PSA

  • Don’t feel pressure. The choices you make can/should be your own.
  • Consent is absolutely, positively, necessary.
  • Embrace self-gov!

Exam Questions

How should I make the cover sheet?
Hand write. It’s easy.

Other Questions

Why three semicolons?
Makes it easier to distinguish 6P’s from other kinds of comments.
Makes it easier to extract/process.

Quiz

Debrief from prior class

Thinking

  • Look back to examples from the reading and try to understand what they were doing.
  • Don’t let the big list distract you. For many things, you’ll focus on one value (or two) and then use map or sort or reduce to work with the larger list.
  • Trust map, reduce, and sort.

Formatting

(define zf->cf (lambda (entry) (append (take (drop entry 3) 3) (take entry 2) (drop entry 5))))

vs.

(define zf->cf
  (lambda (entry)
    (append (take (drop entry 3) 2)
            (take entry 3)
            (drop entry 5))))

Documentation

  • Please use three semicolons for the six P’s, not one.
  • Please put a space after the three semicolons.

Lab

Do the lab on reading data from files

Are we better off doing computations by hand or by computer?
What do you think?
I remember writing sort-by-city, but I can’t find it.
You should be able to write it much more quickly this time.
Did you really mean 51111?
No. Use 50112.
What is the writeup?
Exercise 6
Does Grinnell really have two zip codes?
I was surprised to see that, but it appears that it does.
Or maybe our data are bad.

Debrief

Past labs

  • Yes, it’s helpful to keep the results of your past labs. You should probably make it a practice to email those to your partners.
  • If you use the results of a past lab in a new lab, you should insert a short citation. “sort-by-city taken from lab 9, completed by Stu Dent and An Other”

Other observations

While Wednesday’s lab was a struggle for some of you, this one seemed better (at least from an observer’s perspective). You are mastering complex material.

Naming is important.

(define sort-by-city
  (lambda (c1 c2)
    (string-ci<? (list-ref c1 3) (list-ref c2 3))))

vs.

(define compare-by-city
  (lambda (c1 c2)
    (string-ci<? (list-ref c1 3) (list-ref c2 3))))
(define sort-by-city
  (section sort <> compare-by-city))

Sometimes it’s less important to be perfect than to get the job done. (And sometimes just getting the job done is pretty close to perfect.)

(define city-first
  (lambda (city) (cons (list-ref city 3) city)))
(define search-by-city
  (lambda (cities city)
    (cdr (assoc city (map city-first cities)))))