CSC151.01 2015S, Class 34: Iteration
====================================

* New Partners!

_Overview_

* Preliminaries.
    * Admin.
    * Upcoming Work.
    * Extra Credit.
    * Questions.
    * Exam 2 returned.
* Lessons from yesterday's lab.
* A useful tool for repetition: `for-each`.
* Contrasting `map`, `for-each`, `repeat`, and recursion.
* Lab.
* Debrief.

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

### Admin

* Review sessions Thursday at 9:15am (Sam), 1:15pm (Sam), and 8pm (Alex).
* After reflecting, I flipped the topics for today's class and Friday's class.
  Sorry!
* My severe weather alert warning from KCCI is a "Fire Weather Warning".
  I'm not sure whether it has do do with the date or not.
* Three bad jokes.  One out of three ain't bad.

### Upcoming Work

* Lab writeup!  Problems 8, 9, and 10.
  <http://bit.ly/151-2015S-lab34>
* Reading for Friday: 
    [Geometric Art](../readings/geometric-art-reading.html)
* Assignment 7 distributed: Producing Playful Polygons.

### Extra Credit Opportunities

#### Academic 

* CS Table Friday: Therac 25 (readings back of room or outside my office)

#### Peer Support (Afternoon Section)

* 7:30 p.m. on April 2: Gender as a Process.  EE talks afterwards
  about using mathy things to understand gender.

#### Miscellaneous

* Tonight's "Moving Forward" discussion.
* Contact JMU to host a prospie.  You also get a good dinner in quad and
  the ability to attend an incredible improv show.  Sunday April 12th.
  Most importantly, you convince awesome people that they should come to
  Grinnell.

### Questions

### Exam 2 Returned

Strongest arguments: 

* "The main goal of the exams is that we learn.  We've learned.  Exam grades
   are likely to be relatively consistent across exams, so not counting this exam
   is unlikely to have an effect on students who did not get inappropriate help."
* "Many of us worked very hard on this exam and should see rewards for our
  hard work."
* "You should have a policy that does not discourage people from coming forward."

Learning outcomes from yesterday's lab
---------------------------------------

* Select-all and Delete to clear an image.
* A few small tools and mechanisms for combining them give great opportunity.
* To use turtles successfully, you need to be able to determine where they are
  after each step (and, often, restore some characteristic).

A useful tool for repetition: `for-each`
----------------------------------------

* `map` apply a procedure to each value in a list and make a new list
* Sometimes we don't care about that new list.
  In cases like that, we use `for-each`.
* `for-each` is very useful for spirals.
    * See lab and reading for more details

Contrasting `map`, `for-each`, `repeat`, and recursion
------------------------------------------------------

    > (map (lambda (x) (display x) (newline))
           (list "Happy" "April" "fool" "day"))
    Happy
    April
    fool
    day
    '(#<void> #<void> #<void> #<void>)
    > (for-each (lambda (x) (display x) (newline))
                (list "Happy" "April" "fool" "day"))
    Happy
    April
    fool
    day
    > (repeat 4
              (lambda (x) (display x) (newline))
              (list "Happy" "April" "fool" "day"))
    (Happy April fool day)
    (Happy April fool day)
    (Happy April fool day)
    (Happy April fool day)
    > 

Lab/Debrief
-----------

* Moral 1: You can repeat a basic action to produce a more complex action
  (e.g., for-each with turn/move gives you a spiral).  You can repeat a more
  complex aaction multiple times to produce something even more complex.
* Moral 2: Systematic complex procedures can produce systematic complex
  results.
* Moral 3: Systematic complex procedures can produce surprisingly unpredictable
  results.
* Moral 4: Serendipity
* Moral 2: You can repeat 
