Skip to main content

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

Overview

  • Preliminaries
    • Notes and news
    • Upcoming work
    • Extra credit
    • Friday PSA
    • Exam Questions
    • Other Questions
  • Quiz
  • Debrief
  • Lab
  • Debrief

News / Etc.

  • Quick survey of second-year students.
  • 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
  • CS Extras, Thursday: Study Abroad Programs in CS

Extra credit (Peer)

  • Sunday at 1pm in 3819 an introductory meeting of AppDev. They build mobile apps for campus. No experience necessary.

Extra Credit (Misc)

None at the moment.

Other Good Things

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

Friday PSA

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

Exam Questions

Will the exam take more or less time than a homework?
Probably more.
But please stop at close to five hours (over)
And ASK ME QUESTIONS ALONG THE WAY
Problem 4 is?
Document
and Test
Will we lose points for sensible but really really long and much more
detailed or with extra notes or whatevber than they should be will we
still get full credit or will we lose points and if so how many points
will it be? Did you understand the gist of my question?
You will get most of the points.
But you may lose a point or two if you have one that is especially over-complex or over-long or both.
Why did you comment out the test suite in the last one?
So that when you click “Run” before you’ve tried to solve the problem, you don’t get screenfuls of error messages.
You should uncomment them before submitting.
And add your own

Questions

Should we email you in advance for events?
Yes, email me with “CSC 151 EXTRA CREDIT OPPORTUNITY” as a subject.
What is the alternative to the Ctrl-up-arrow on Mac?
Esc then p
Esc then n for next

Quiz

If you finish early, please review the reading.

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) (d
rop entry 5))))

vs.

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

Naming

(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))

Documentation

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

Lab

How do I get the sort-by-city procedure?
Your notes?
Today’s eboard? (Eboard 10)
See below.
What’s a way to tell if I have a bad latitude, as in the
'("09123" "" "" "Apo" "AE" "") from the previous lab?
Search to see of “09123” is in the list. That’s a good first candidate. (assoc "09123" zips)
Rearrange the list to put the latitude first and then use assoc. (assoc "" (map cdr zips))
Try to sort by latitude. (sort zips (lambda (c1 c2) (> (cadr c1) (cadr c2))))

Debrief

Retaining past work

I didn’t save our answers from the past lab / my partner has our answers
from the past lab.
You should probably save your lab work so that you can use it in the future - followup problems (other labs, homework, exams), studying, etc.
Arrange to get past labs from partners.
I used answers from a past lab / this eboard. Should I cite?
Certainly.
sort-by-city taken from notes on lab 9 by S. Quirrel and S. Carlett aka “double r, double s, double t”.

Don’t overwork yourself or the computer

I need to search by city. I can only search by the first thing. The
city is 4th.
Write something to add the city to the front (define city-first (lambda (entry) (cons (cdddr entry) entry)))
Do that to every element.
Use assoc.