CSC151.02 2016S, Class 09: Writing Your Own Procedures, Continued
=================================================================

_Overview_

* Preliminaries.
    * Admin.
    * Upcoming Work.
    * Extra Credit.
    * Questions.
* More about procedures.
* Lab, continued.
* Questions and reflection.

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

### Admin

* Old partners!
* Today's lab is a continuation from Friday's class.
* Our graders sent back preliminary grades on your lab writeups.  Those will
  generally be on a 0/1 scale (not submitted or significantly incorrect
  gets a 0; everything else gets a 1).  
* If you would like to be added to the CS Department's Mailing List for
  events, please send me email.
* Quiz 2 returned.  We need to talk about the last problem.
* Prospie!

### Reminders

* Office hours: MTWF 10-11, Tu 1-2.
    * Sign up at <http://rebelsky.youcanbook.me>.
    * Also feel free to stop by when my door is open.
    * Or to email me for an appointment.
* Tutor hours
    * Sunday, 3-5 p.m.
    * Sunday-Thursday, 7-10 p.m.
* Weekly review sessions:
    * Wednesday at 8pm in the CS Commons with ?
    * Thursday at 10am in this room with SamR
    * Thursday at 8pm in the CS Commons with ?

### Upcoming Work:

* Readings for Tuesday:
    * [Simple Output in Scheme](../readings/output-reading.html)
    * [Simple Input in Scheme](../readings/simple-input-reading.html)
* [Assignment 3](../assignments/assignment.03.html) due tomorrow
  at 10:30 p.m.  
* Lab Writeup: Exercises 3 ab and 5
    * Send email titled __CSC 151 Lab Writeup 9 (Your Names)__
    * Do not include the underscores.
    * Send to <CSC151-02-grader@grinnell.edu>
    * Due before class on Wednesday.

### Extra Credit

* Send to <rebelsky@grinnell.edu> with subject "CSC 151 Extra Credit".

#### Academic

* This week's Rosenfield Symposium on Campaign Finance
* Monday, February 8, 4:15 p.m. in Bucksbaum 152, Miriam Langer enjoins you to 
  "Do Your Work in Public" 
  (part of the series "Digital in Public: Intellectual and Technical Skills 
  for Making a Difference")
* Monday, February 8, 7:30-9:00, JRC 101: The Complex Relation Between 
  Alcohol and Sexual Assault
* Noon Tuesday in the White PDR: Bowie, Mickey, and the NFL: Copyright in
  the 21st century (copies of the reading outside Sam's office)
* 7:30 pm Tuesday in ARH 131 - Funding for unfunded internships
* Thursday at 4:15 in 3821 - Life After Grinnell (for CS students)
* Anything in next week's Carnival and Creativity series

#### Peer

* Track and Field February 13. 
* Love Notes.  If the $2 is a stretch, Sam will pay.  Email JS the elder.

#### Regular Peer

* Social Dance Workshop Tuesdays 7:00-8:00 in Bucksbaum Dance Studio
  (starting this week)
* Pun club Saturdays at 4pm in Younker (max 2)
* Socrates Cafe' Saturdays (max 2) email [socratescafe] to be added
  to the mailing list to hear about the top secret meeting location
* Electronic Potpourri on KDIC Fridays at Five
* Wednesday, 7:30, ARH 120, Environmental Movie

### No Extra Credit, But Still Good

* High School Large Group Speech Presentations Saturday at 6:30 p.m. 
  (I think) at the high-school auditorium.

### Quiz

    (define fave (irgb 250 0 42))
    (define fave2 (irgb-lighter (irgb-darker fave)))
    (irgb-complement fave)

* The way we express values is important, so "250/0/42" (that's for
  `(irgb->string fave)`.
* `(irgb-complement fave)` does not change `fave`; it just computes
  a new color
  
The last problem: Write a procedure that adds 32 to each component.

Three possible strategies:

* `lambda`.
* `section`.
* `compose`.

We need to use compose.

    (define irgb-much-lighter (compose irgb-lighter irgb-lighter)) ; not allowed
    (define irgb-much-lighter (compose irgb-redder irgb-greener irgb-bluer))
    (define irgb-much-lighter (compose irgb-complement irgb-darker irgb-darker irgb-complement))

Similar questions were in the mentor sessions and in the notes.  (And no,
we did not intend to give a particular advantage to those folks.)

### Questions

_Can we write `define` in the middle of a procedure?_

> No.

_Did you even look at what you wrote for problem 4?_

> I thought so.  I'll fix it during class.

_How much info should we provide when citing other groups?_

> Approximately: "I talked to Tulah's Two Taylors about problem 4 and they
  provided me with advice on it."

_How should we cite code from the assignment?_

> I don't require you to cite code from assignments.

> If you choose to cite such code, use something like "Taken from 
  assignment 3 at <http://www.cs.grinnell.edu/~rebelsky/Courses/CSC151/2016S/assignments/assignment.03.html>."

> Or

        Curtsinger, C., Davis, J., Rebelsky, S. A., and Weinman, J. (2016).
        _Assignment 3: Color Transformations and Image Filters._  Grinnell
        College, Dept. of CS.  Online document at
        <http://www.cs.grinnell.edu/~rebelsky/Courses/CSC151/2016S/assignments/assignment.03.html>, last modified 2016-02-01; visited yesterday.

_How can we wrap around given that the remainder function doesn't take
 decimals?_

> Option 1: Round to the nearest integer.

> Option 2: Use a more clever calculation.


More about procedures
---------------------

   (define square
     (lambda (num)
       (* num num)))

   (define square
     (lambda (renn)
       (* renn renn)))

   (define square
     (lambda (color)
       (* color color)))

Scheme doesn't care what you call your parameters!  So choose a name that
makes sense to your human reader.

Be careful about what you name your parameters, as they can override existing
names.

    (define square
      (lambda (*)
        (* * *)))
        
    (define square
      (lambda (+)
        (* + +)))

Ugh.
        
Lab, continued
--------------

Writeup: 3 ab and 5

Questions and reflection
------------------------

