CSC151.01 2014F, Class 42: Higher-Order Procedures, Revisited
=============================================================

*New partners!*

_Overview_

* Preliminaries.
    * Admin.
    * Upcoming Work.
    * Extra Credit.
    * Notes on the project.
    * Questions.
* Introductory comments.
    * Some program design principles.
    * Thinking about repeated work.
    * Procedures as first-class values.
* Reflection.
* Lab.

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

### Admin

* Exam 3 returned at the end of class.
    * Notes to be distributed this evening.
    * Quizzes to be returned tomorrow.
* Office hours recomplicated by interviews and administrative junk.  Sorry.
    * Right now, I don't even know what they are or will be.
* Today's topic is complex; I assume we'll have more questions than 
  normal.

### Upcoming Work

* Lab writeup: Exercises 3 & 4: <http://bit.ly/151-2014F-w42>
* Reading for Tuesday:
    * [Analyzing Procedures](../readings/analysis-reading.html)
* Part one of the project due tonight!
    * Sketches due in class on Tuesday.
* Part two of the project due next Tuesday.

### Extra Credit Opportunities

#### Academic

* CS Extras Thursday: Weinmaniacs on Text Recognition in Maps
* CS Table Friday: One Year After Healthcare.gov
* CS Extras Tuesday the 25th: Summer Opportunities in CS

#### Peer Support

* Why didn't anyone mention the ISO dinner?
* Karan's radio show 11pm Thursday nights on KDIC
* Evan's radio show 5pm Friday nights on KDIC 
* Donna's radio show Sunday midnight on KDIC
* One acts, coming soon

#### Miscellaneous

* VP Student Affairs Candidate Open Sessions
    * Wednesday, 4:15, JRC 209
    * Friday, 4:15, JRC 209

### Project Notes

* Remember that you need at least three different approaches from the
  menu of Gimp tools, Turtles, image-compute, image-variant, drawings
  as values, and color trees.  (If you want to suggest another, ....)
* `(image-redo! image (lambda (x y color) newcolor))` is the generalization
  of `image-transform!` and `image-compute`.
* Can we use `turtle-teleport!` and `turtle-face!`?  Yes.

### Questions

Some program design principles
------------------------------

* Hope: How to write "elegant" algorithm
* Keep it small, if possible
    * Potentially more efficient
    * Faster to write (for the programmer)

        (map (l-s + 4) (iota 10)) vs. recursive

    * Potentially more readable
* Don't rewrite nearly-identical code
    * let helps us handle this issue
    * Helper functions that encapsulate the similarity
* Only name the things that have to be named

Thinking about repeating work
-----------------------------

* Reading three variants of the same approach teaches you something; after
  that, more reading doesn't help
* Writing three variants of the same approach teaches you something; after
  that, more writing doesn't help
* Ideally, we should be able to generalize any approach we use (and turn
  it into a function)

Procedures as first-class values
--------------------------------

* When you generalize, you might want to have procedures as parameters
  (as in `map`) or return procedures as values (as in `l-s`).
* Scheme lets you do this.  Not all languages do.

Reflection
----------

What did you learn from the reading?

What do you still find puzzling or murky?

* What's the diff between apply and map?

Lab
---


