---
title: Eboard 25  Pairs and pair structures
number: 25
section: eboards
held: 2017-10-27
---
CSC 151.01, Class 25:  Pairs and pair structures
================================================

_Overview_

* Preliminaries
    * Notes and news
    * Upcoming work
    * Extra credit
    * Friday PSA
    * Questions
* Quiz
* Representing lists with pairs and cons cells
* Lab
* Debrief

### News / Etc.

* A request.
    * Treat others with respect.  (Sounds easy)
    * Even when they don't treat you with respect.  (Much harder)

### Upcoming Work

* [Writeup for class 24](../writeups/writeup24) due Friday at 10:30 p.m.
    * Exercise 6.  (No documentation necessary.)
    * To: <csc151-01-grader@grinnell.edu>
    * Subject: CSC 151.01 Writeup 24 (YOUR NAMES)
* [Writeup for class 25](../writeups/writeup25) due Monday at 10:30 p.m.
    * Exercises 1 and 3.
    * Hand to: Sam (or under Sam's door)
* [Assignment 6](../assignments/assignment06) due Tueday
    * Although the assignment says that you have assigned pairs, I will
      permit you to choose your own partners (or to work in individuals
      or trios).
* Read [Vectors](../readings/vectors) for Monday's class.
    * Still under development; should be ready tonight.

### Extra credit (Academic/Artistic)

* Protest Bot workshop, TODAY 4pm in Burling 1st.  
* Rebirth Brass Band, Wednesday, 7:30pm somewhere.

### Extra credit (Peer)

* Women's Soccer vs. Um and one Saturday.
* Grinnell Singers Sunday at 2 p.m. in Sebring Lewis.

### Extra credit (Misc)

* Pioneer Weekend in about two weeks: A one weekend innovation challenge.
  Registration at <https://grinnell.co1.qualtrics.com/jfe/form/SV_0oKEvGlV5twGczr>

### Other good things

* Star Wars Music Talk TODAY at 4pm.
* Swimming and Diving meet Saturday (9am to 1pm).
* SGA Tailgate on the Grassy Knoll, Saturday at 11:30.
* Football Saturday.

### Friday PSA

### Questions

Can we use `take` and `drop` on problem 1?
  : No.

Are you sure?  It seems stupid not to be able to use them?
  : You are right.

On problem 1, how should I decide how many elements to take?
  : If you have ten and I say two parts, how many go in the first
    list?  A: Five.  Q: How many are left?  A: Five.  How many
    do you have to break that into?  A: One.
  : If you have nine and I say two parts, how many go in the first
    list?  A: Five.  Q: How many are left?  A: four.  How many
    do you have to break that into?  A: One.
  : If you have nine and I say four parts, how many go in the first
    list?  A: Three.  Q: Why?  A: It could also be two, but I decided
    to round up because that's what you did in the example.  Q:  How
    many are left: A: Six.  Q: How many parts?  A: Three.
    do you have to break that into?  A: One.

Recursion is one of those complex issues in CSC 151.  How is it going?
   : [4] I don't get it at all / I barely understand.
   : [14] I can take a pattern and replace, but I don't really understand
     what's going on.
   : [20] I feel reasonably comfortable with recursion.  I know how to
     take advantage of the Recursion Fairy's brilliance.
   : [1] Recursion is obvious, why is Sam even asking if it's hard.
  
Representing lists with pairs and cons cells
--------------------------------------------

We build lists a lot in Scheme.  We can do lots of things with lists.

Behind the scenes, the computer has to keep track of what's in the list
and how the list is organized.

It is organized in these things called "cons cells" or pairs.  Each consists
of two related references to other things (the `car` and the `cdr`).  The
first reference contains the value at that point in the list.  The second
reference is the remainder of the list.  

At the end of the list the cdr/next element is `null`.  If any of the
cdrs are neither pairs nor null, then it's not a list.

Detour
------

```
> (filter (negate funny?) todays-sam-jokes)
'("Wear your Chucky T's to A Converse with the Stars"
  "Pairs from Harry and David"
  "Harris party with the Magic Recursion Fairy"
  "What's up?  White ceiling tile."
  "(filter (negate funny?) todays-sam-jokes)"
  ...)
> (filter funny? todays-sam-jokes)
'()
```

Sam, why are you typing random things in the eboard?
  : To keep the people who are done with the quiz amused.  But they
    really should just bring up the lab and start looking at it.

Lab
---

Writeup #1 and #3.

Problem 5 question: When can you take the `cdr` of `val`?  (Can you take
the `cdr` of `null`?  Of 5?  Of your mentor?)

Debrief
-------

