CSC151.02 2016S, Class 17: Boolean Values and Predicate Procedures
==================================================================

_Overview_

* Preliminaries.
    * Admin.
    * Upcoming Work.
    * Extra Credit.
    * Questions.
* Numbers vs. Images.
* Testing.
* Lab.

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

### Admin

* New partners!
* Sam is incredibly behind on grading.  Quizzes returned tomorrow.
  Exams may take another week.
* If you invoked "There's more to life", wait until you get your exam
  back to meet with me.
* We'll talk a little bit about testing.

### 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 #Sorry Sarah
    * Thursday at 10am in this room with #Sorrier SamR
    * Thursday at 8pm in the CS Commons with #Apologetic Alex

### Upcoming Work:

* Reading for Tuesday
    * [Conditionals](../readings/conditionals-reading.html)
* [Assignment 4](../assignments/assignment.04.html) due Tuesday night
  at 10:30 p.m.
* Lab Writeup: Exercise 1c.
    * Send email titled __CSC 151 Lab Writeup 17 (Your Names)__
    * Do not include the underscores.
    * Send to <CSC151-02-grader@grinnell.edu>
    * Due before class on Wednesday.

### Extra Credit

* Send your reports to <rebelsky@grinnell.edu> with subject 
  "CSC 151 Extra Credit".
* Send opportunities to me before class with subject
  "CSC 151 EXTRA CREDIT OPPORTUNITY!"

#### Academic

* Sexual Assault Awareness Week Discussion, Monday, 7:30 pm JRC 101
* CS Table, Noon, Tuesday, White PDR.
* State of SHACS Discussion, Tuesday, 7pm JRC 209
* Town Hall, Wednesday, noon or 7:30 pm (I think) JRC 101

#### Peer

* Pun Club Tournament Friday the 26th in the evening (Bobs).
* Contra Dance Friday the 26th in the evening (Main).
* Improv Show the 27th in the evening in Loose Lounge (7:30).
* Vote for SGA positions.
* Go to Wednesday's SGA meeting to make noise about the reserve.
* AppDev Pub Night, Friday, 8pm, Lyle's (JRC Basement).
* Black History Month Showcase, Friday, Harris, 7:30 p.m.

#### Regular Peer

* Social Dance Workshop Tuesdays 7:00-8:00 in Bucksbaum Dance Studio
* Pun club Saturdays at 4pm in Younker (max 2)
* Electronic Potpourri on KDIC Fridays at Five (TONIGHT)
* Space Odyssey KDIC Fridays at Six

### No Extra Credit, But Still Good

### Questions

Numbers vs. Images
------------------

* Images are misleading.
* Numbers are telling.

Testing
-------

We'll work on some simple tests for `smaller-neighbor`.

* Goal of smaller neighbor: Make a copy of the same drawing, right next
  to it, but smaller.
* "Right next to each other" = "The borders are touching" = 
  "The right of the orignal = the left of the neighbor" =
  `(drawing-right original) = (drawing-left neighbor)`.
* Same shape.
* Same color.
* Proportionally smaller width and height (3/4 as big)
* Top should be the same

As a procedure.

<pre class="programlisting">
(define check-right-neighbor
  (lambda (drawing neighbor)
    (check-= (drawing-right drawing)
             (drawing-left neighbor)
             .00001
             "next to each other")
    (check-= (drawing-top drawing)
             (drawing-top neighbor)
             .00001
             "tops aligned")
    (check-equal? (drawing-color drawing)
                  (drawing-color neighbor)
                  "same colors")
    (check-equal? (drawing-type drawing)
                  (drawing-type neighbor)
                  "same shape")
    (check-= (* 3/4 (drawing-width drawing))
             (drawing-width neighbor)
             .00001
             "proportional width")
    (check-= (* 3/4 (drawing-height drawing))
             (drawing-height neighbor)
             .00001
             "proportional height")))
</pre>

Here's what we saw (more or less).

<pre class="screen">
Welcome to DrRacket, version 6.1 [3m].
Language: racket [custom]; memory limit: 128 MB.
; Manually build a rectangle and its neighbor
> (define rect1 (rectangle "red" 50 30 20 20))
> (define rect2 (rectangle "red" 65 30 15 15))
> (check-right-neighbor rect1 rect2)
--------------------
FAILURE
name:       check-=
location:   (#&lt;path:/home/rebelsky/Desktop/class17.rkt&gt; 109 4 3110 124)
expression: (check-= (drawing-right drawing) (drawing-left neighbor) 1e-05)
params:     (70 65 1e-05)
message:    "next to each other"

. . Check failure
--------------------
; Okay, the left edge of rect2 was in the wrong place.  Fix it.
> (define rect2 (rectangle "red" 70 30 15 15))
> (check-right-neighbor rect1 rect2)
; Now we get no errors.  What happens if we recolor?
> (define rect2 (rectangle "grey" 70 30 15 15))
> (check-right-neighbor rect1 rect2)
--------------------
FAILURE
actual:     16711680
expected:   8421504
name:       check-equal?
location:   (#&lt;path:/home/rebelsky/Desktop/class17.rkt&gt; 117 4 3359 113)
expression: (check-equal? (drawing-color drawing) (drawing-color neighbor))
message:    "same colors"

. . Check failure
--------------------
; As expected, it tells us that the colors are not the same.
; Let's check the wrong shape.
> (define rect2 (ellipse "red" 70 30 15 15))
> (check-right-neighbor rect1 rect2)
--------------------
FAILURE
actual:     rectangle
expected:   ellipse
name:       check-equal?
location:   (#&lt;path:/home/rebelsky/Desktop/class17.rkt&gt; 120 4 3477 110)
expression: (check-equal? (drawing-type drawing) (drawing-type neighbor))
message:    "same shape"

. . Check failure
--------------------
; Now, let's see whether our smaller-neighbor procedure works.
> (check-right-neighbor rect1 (smaller-neighbor rect1))
--------------------
FAILURE
name:       check-=
location:   (#&lt;path:/home/rebelsky/Desktop/class17.rkt&gt; 109 4 3110 124)
expression: (check-= (drawing-right drawing) (drawing-left neighbor) 1e-05)
params:     (70 115/2 1e-05)
message:    "next to each other"

. . Check failure
--------------------
--------------------
FAILURE
name:       check-=
location:   (#&lt;path:/home/rebelsky/Desktop/class17.rkt&gt; 113 4 3239 115)
expression: (check-= (drawing-top drawing) (drawing-top neighbor) 1e-05)
params:     (30 45/2 1e-05)
message:    "tops aligned"

. . Check failure
--------------------
; Two failures!  The right and left edges don't match (way off) and
; the tops don't match (also off).
</pre>

Lab
---

Writeup: 1c.
