---
title: Eboard 11  Reading lists and tables from files
number: 11
section: eboards
held: 2018-02-14
link: true
---
CSC 151.01, Class 11:  Reading lists and tables from files
==========================================================

_Overview_

* Preliminaries
    * Notes and news
    * Upcoming work
    * Extra credit
    * Questions
* Leftover topics from last class.
* Lab
* Debrief

Preliminaries
-------------

### News / Etc.

* New partners!
* Happy Valentine's day.
* Yesterday, someone said "I didn't realize that I could ask you questions
  about the exam."  So, please know that it is okay to wander by my office
  and ask questions or to email questions (and to re-email them if I
  don't respond).

### Upcoming work

* [Flash cards](../flashcards/flashcards04) due TODAY at 5pm.
    * I do hope to get them summarized this week.
* [Exam 1](../assignments/exam01)
    * Cover sheet due in class TODAY
    * Epilogue due TONIGHT
* [Lab writeup for class 11](../writeups/writeup11), due before class Friday.
    * Exercise 6
    * "CSC 151.01 Writeup for Class 11 (Your Name)"
    * Mail to <csc151-01-grader@grinnell.edu>
* Readings (due before class Friday)
    * [Boolean values and predicate procedures](../readings/boolean)
    * [Filtering lists](./readings/list-filters)
* Quiz Friday
    * Topics: Testing, tables, heterogeneous lists
    * Review sessions Thursday at 7pm and 8pm in Science 3821
* [Homework 4](../assignments/assignment04) due next Tuesday
    * Today's partners are your HW partners.

### Extra credit (Academic/Artistic)

* Visit the two exhibits at the Faulconer Gallery.
* TODAY, Feb. 14 at 4:15 p.m. in Noyce 2021: Cool CS Alumni 
  talk about inclusion, life, and career after Grinnell.
* TONIGHT, Feb. 14 at 8:00 p.m. Women and Non-Gender-Conforming People
  in CS (with special guests) in the CS Commons.
* TOMORROW, Feb. 15 at 7:00 p.m. in Harris.  _Deej_ the Film.

### Extra credit (Peer)

* Listen to KDIC Wednesdays at 6pm - Witty banter with other personalities
  and/or co-host.  Also Indian, Arabic, and Farsi music.  (Up to two 
  units of extra credit.)
* Math SEPC study break 7pm today.  Crafts and candy.
* Wednesday (February 14th), the Langan CAs will be co-hosting an event with 
  SHIC about sex positivity and SHIC resources. The event will most likely 
  take place 8:30-9:30pm in Langan first lounge.  There will definitely be
  food.
* Peer editing with SS.  Talk to SS about the details.  Make your
  English Lit more literate.
* Midwest Swim and Dive Conference.  10am Friday to 5pm Sunday.
     * 30 minutes counts.

### Extra credit (Misc)

* Participate in Islamic awareness week.
    * MAP Presentation today at 4:15 in JRC 209
    * Tomorrow at 4pm: Councilwoman at Drake
    * Friday at 4pm in CRSSJ: Turkish Delights, Henna
    * Friday at 2:15pm in CRSSJ open prayer
* Lunar New Year Festival, 6:30 p.m.  Harris Gym.

### Other good things

* Art House movie at 7:30 pm TONIGHT.  _Call me by your name_.

### Questions

_Will you explain how to do problem 6?  How about the most general case?_

> Yes.  I plan to go over the exam on Monday.  I also plan to distribute 
  an answer key.

_Do you know that exams 2, 3, and 4 are online?_

> Yes.  Those are last semester's.  All of the old exams for this class
  are online somewhere.  The hope is that none of the solutions are online.
  (But if you find the solutions online, use them, and cite them, you do
  get full credit.)

_Can I write csv files on my Mac?_

> Yes.  But make sure to save as a text file not as an RTF file (which is
  the default).

_Do I have to resubmit if I included the incredibly accurate statement
**There's more to life than CS** in the file?_

> No.

There seems to be a line missing in the reading.

> Yup.

```
> (define courses (read-csv-file "/home/rebelsky/share/csv/courses.csv"))
```

_Can it hurt me to write "There's more to life?"_

> Only if you are worried about writers cramp or exploding pens.  It will
  not negatively affect your grade on the exam or my opinion of you.


Leftover observations from last class
-------------------------------------

`sort` and `tally` (and, soon `filter`), like `map` and `reduce`, do
something to a list by repeatedly using another procedure.

* `map` applies the procedure to individual elements and gives a new list.
* `reduce` repeatedly applies the procedure to neighboring pairs of elements 
  and gives a single value
* `sort` rearranges the list by applying the procedure to pairs of value and
  swapping the position of pairs that are out of order.
* `tally` counts elements in the list by applying a procedure that determines
  whether or not a value counts.

We will find that it becomes useful to focus on the procedures that `map`,
`reduce`, `filter`, and `sort` use. ("First solve it for an element or
a pair.  Then generalize to a list with `map`, `reduce`, or `sort`."
Or "**Solve for one, then for many.**")

* In the case of sorting, we tend to focus on comparing two values.

Make it a habit to write the four P's for every procedure you write.

Lab
---

Writeup: Exercise 6

Debrief
-------

_Most of this is left for the next class._

Observation: Some of you did not have your prior lab.  You will find prior
labs useful for all sorts of purposes.  Please ask your partner to send you
the lab at the end of each class.

* We asked you to use that code in part to remind you of those issues.
    * The code you've written might again be useful.
    * You should therefore make sure you have a copy
* We also asked you to use that code to help you practice citing things.

Observation: Many of you found the length and then used that number in
your future calculations.  E.g., `(drop (- 45751 5) lst)`.  You'd be
better off using the call to length.  E.g., `(drop (- length 5) lst)`.

Observation: Some of you tried to skip exercises 4 and 5 and jump straight
to exercise 6.  But exercise 6 requires exercises 4 and 5.  If you skip
exercises, you should read over them first.

```
;;; Procedure:
;;;   zip->city
;;; Parameters:
;;;   zip, one of those silly zip-code lists
;;; Purpose:
;;;   Exract the city
;;; Produces:
;;;   city, a string
(define zip->city
  (section list-ref <> 3))

;;; Procedure:
;;;   prepend-city
;;; Parameters:
;;;   entry, one of those silly zip lists
;;; Purpose:
;;;   Shove a copy of the city name at the front of the list
;;; Produces:
;;;   citified, a list
;;; Preconditions:
;;;   entry has the form ...
;;; Postconditions:
;;;   (cdr citified) = entry
;;;   (car citified) is a string that names the city
(define prepend-city
  (lambda (entry)
    (cons (zip->city entry) entry)))
```

```
> (cdr (assoc "Grinnell" (map prepend-city zips)))
'("50112" 41.685324 -92.630258 "Grinnell" "IA" "Poweshiek")
```
