---
title: Eboard 10  Tables and compound data
number: 10
section: eboards
held: 2018-02-12
link: true
---
CSC 151.01, Class 10:  Tables and compound data
===============================================

_Overview_

* Preliminaries
    * Notes and news
    * Upcoming work
    * Extra credit
    * Questions
* Formatting your code
* About quiz 3
* The reading(s)
* Lab
* Debrief

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

### News / Etc.

* New partners!
* My life continues to be a Robert Burns poem.  I spent 9am to 10pm on
  Saturday at family events.  I dealt with a stupid software bug for 
  eight hours on Sunday.  I do intend to catch up on stuff, but ....
    * Please do not emulate me.  (Well, family events are good.)
* If I haven't had you start lab by 9:00 a.m., throw something at me.
    * Preferably something soft.

### Upcoming work

* [Exam 1](../assignments/exam01)
    * Exam due TOMORROW night at 10:30 p.m. in electronic form.
    * Cover sheet due in class on Wednesday
    * Epilogue due Wednesday
* [Lab writeup for class 10](../writeups/writeup10), due before class Wednesday.
    * Exercise 4
    * "CSC 151.01 Writeup for Class 10 (Your Name)"
    * Mail to <csc151-01-grader@grinnell.edu>
* Readings (due before class Wednesday)
    * [Reading data from files](./readings/data-from-files)

### Extra credit (Academic/Artistic)

* Visit the two exhibits at the Faulconer Gallery.
* CS Table Tuesday: Accessibility
    * Florian Beijers. A vision of coding, without opening your eyes. Medium. Jan 27, 2015.  <https://medium.freecodecamp.org/looking-back-to-what-started-it-all-731ef5424aec>
    * Kiley Sobel, Kyle Rector, Susan Evans, and Julie A. Kientz. Incloodle: Evaluating an Interactive Application for Children with Mixed Abilities. CHI 2016, ACM. May 7, 2016.  <https://www.hcde.washington.edu/files/news/Incloodle.pdf>
* Tuesday, Feb. 13 at 7pm in JRC 209: _Creating Solutions with Design 
  Thinking Tools_.  Join CEO and Founder of Human Centered Innovation,
  Megan Goering ’08, to learn specific strategies of human centered
  design that will help take your problem solving ideas to the next level.
* Wednesday, Feb. 14 at 4:15 p.m. in Noyce 2021: Cool CS Alumni 
  talk about inclusion, life, and career after Grinnell.

### Extra credit (Peer)

* Listen to KDIC Wednesdays at 6pm - Witty banter with co-host and 
  Indian, Arabic,
  and Farsi music.  (Up to two units of extra credit.)
* 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.
* Peer editing with SS.  Talk to SS about the details.  Make your
  English Lit more literate.

### Extra credit (Misc)

### Other good things

* Participate in Islamic awareness week.

### Questions

What's a carriage return?
  : A relic of the typewriter age.
  : When I say "Use carriage returns" I mean "break the code into 
    lines at reasonable/appropriate places"

I hear something about a "good faith grade guarantee".  Can you explain that?
  : Sure.  If you miss no more than two classes (with a few exceptions) and
    attempt all the work, you are guaranteed to pass with at least a C+.

Can you talk a bit about formatting of code?
  : Sure.  I'll add a section below.

I don't understand the documentation of `city-city<?` from the reading.  Why does it produce a Boolean value rather than a sorted list?
  : That's an interesting question.
  : We're starting by comparing individual cities.
  : The sort routine repeatedly applies that procedure to figure out the
    correct order.

```
> (define montgomery '("Alabama" "Montgomery" 32.361538 -86.279118))
> (define juneau '("Alaska" "Juneau" 58.301935 -134.41974))
> (city-city<? montgomery juneau)
#f
> (city-city<? juneau montgomery)
#t
```

Why don't our graders give more feedback?
  : Because (a) they may not be able to give detailed feedback; (b) they
    don't have the time; and (c) it's not clear that it's worth it.

Formatting your code
--------------------

You have multiple goals in writing code.

* The code should achieve its purpose.
* The code should be clear to the human reader.

Here's a sample procedure.

```
(define something (lambda
(x) (map (o
increment 
increment) (iota
x))))
```

```
(define something (lambda (x) (map (o increment increment) (iota x))))`
```

Code that is easier to read is often easier to fix.

Ctrl-i reindents.  Yay.

Lots of formatting is custom.

* `(define name` goes on a line by itself.
* `(lambda (params)` goes on a line by itself.
* Arguments to a procedure call either go
  (a) all on the same line or (b) one per line
* Don't have parentheses on lines by themselves ("floating parentheses")
* Choose good names.

The code above becomes

```
(define ints-from-2
  (lambda (x)
    (map (o increment 
            increment)
         (iota x))))
```

About the quiz
--------------

### Document `double`

```
;;; Procedure:
;;;   double
;;; Parameters:
;;;   num, a number
;;;     Note: We can double complex numbers.
;;;     Note: Name, Type
;;; Purpose:
;;;   Compute twice num
;;; Produces:
;;;   doubled, a number
;;;     Note: Name, type
;;; Preconditions:
;;;   [No additional]
;;; Postconditions:
;;;   * doubled = (* 2 num)
;;;       Note: We specify the *value* of the result.
;;;   * doubled has the same "type" as num.  If num is exact, doubled
;;;     is exact.  If num is complex, doubled is complex.  If num is
;;;     an integer, doubled is an integer.  And so on and so forth.
;;;       Note: This second postcondition is not strictly necessary,
;;;         since the first postcondition implies it.
```

### Doubling a list

Expected

```
(define double-list
  (lambda (lst)
    (map double lst)))
```

Hoped for

```
(define double-list
  (section map double <>))
```

The readings
------------

**There was not time for this section because Sam wanted to make sure
that students had time for lab.  Plus, he'd been it by flying fruit.**

_What did you see as the big lessons from the reading?_

_Why represent compound data with a list rather than a string?_

Lab
---

_Issues to be covered next class._

`sort` and `tally`, 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`, 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.

Debrief
-------

_To be covered next class._

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

Focus on "solve for one, then for many"

