# Week 11

## Random Functions, Local Expressions, Abstraction / Midterm 2

### Monday

- Recipe Card Check

- Assignment 3 posted - Permutations
- Assigned: Nov 13 (today)
- Due: Nov 27 (two weeks)

- Lecture 13: Random functions and Local expressions

- Lecture 14: Abstraction, Higher Order Functions

- check-syntax-example.rkt

### Wednesday

- Recipe Card Check
- Exam Promises for Midterm 2
**to come**

- Handout: Spring 2017 Midterm 2
- sample solutions from class: sample-midterm2-sols.rkt

- Exam Promises for Midterm 2
- 75 points / 75 minutes
- Budget your time one point per minute
- Open book / open notes
- since our book and notes are accessed on a computer, and we're trying to save paper…
- you may login to your CS accounts and view the HtDP/2e textbook in a browser
- you may open DrRacket for the purpose of viewing the lecture notes, labs, and assignments
- but you may not run any programs or use the Interactions pane in DrRacket to evaluate any expressions (you're on your honor)

- Exam is cumulative, but with an emphasis on the material covered since the first midterm
- Lectures 7–12
- HtDP/2e Parts:
- II Arbitrarily Large Data
- IV Intertwined Data

- Topics:
- lists, list abbreviations
- functions that consume lists, functions that consume multiple lists
- binary trees (e.g., rumor mill, pipeline), and functions that consume them
- intertwined data, mutually referential data definitions, mutually recursive functions (e.g. more realistic rumor mill, files and directories), and functions that consume intertwined data

- 5 questions, 15 points each
**Q1**List expressions: Given one or more lists, evaluate and write expressions involving the list functions (cons, first, rest, cons?, empty?) and/or convert both ways between cons and abbreviated lists.**Q2**Dr. Seuss-inspired function: from*The Cat in the Hat Comes Back*.- The function you will be asked to write will be for a data definition I give you based on this class children's book. (It will be another variation of a list-like data definition, like the Russian Dolls from HtDP/2e: Section 9.4.
- You will be asked to write a function that consumes a Cat (from the given data definition).
- Even though this may seem to be something completely different, the Data Definition will really be a thinly-veiled list! Design Recipe.

**Q3**Multiple Lists Function. You will be asked to write a function that consumes two lists. Based on Lecture 9, Multiple Complex Inputs. I'll even promise you it will be of the second variety (`parallel-sum`

was an example of this variety).- The question I ask you to write will be a variation of the question on the sample test.

**Q4**Binary Tree Function. I provide the data definition, you write the function. Design Recipe.- I will even promise you it will be the same definition of a binary tree as on the sample test, but…
- The function I will ask you to write will be different.

**Q5**Function based on intertwined data: This question will be based on the data definitions for Files and Directories, from Lecture 12. I provide the data definition, you write the function(s). Recall: for intertwined data, when you are asked to write a function, you actually write multiple functions, one for each data definition. Design Recipe.- Again, the function(s) I ask you to write will be a variation of the function on the sample test.

### Thursday

- Midterm 2