CSC151.02 2015S, Review Session 2: Starting Scheme
==================================================

_Overview_

* You ask questions, I attempt to answer.
* I ask questions, you attempt to answer.
* We look at some sample quiz questions.

_Admin_

* If you don't come to review sessions and count on other people to ask
  questions, you may not get your questions answered (particularly if
  no one shows up to review sessions).
* You can use review sessions as a time to sit and work on lab and ask
  me questions when they come up.

Your Questions
--------------

_What's an argument?_

> Another name for parameter.

> Some people use "parameter" for "thing in procedure declaration" and
  "argument" for "thing in procedure call".

> We are not that careful.

_How do I type complex numbers?_

> Number plus/minus number letter i, as in the following.  No spaces allowed!

        > 3+4i
        3+4i
        > (* 3+4i 3+4i)
        -7+24i
        > 3-4i
        3-4i

> Here's what happens if you have spaces

        > 3 + 4i
        3
        #<procedure:+>
        4i: undefined;
         cannot reference an identifier before its definition

_For the quiz, do we have to understand that weirdo representation of
 drawings, like `(drawing ellipse 123123 "" 10 20 30 40)`._

> No.

> In case you care, it's the symbol 'drawing, the symbol 'ellipse, a
  strange numeric representation of the color, something pointless, the
  left boundary, the top boundary, the width, and the height.

_Can you explain why we get the result we do for `(modulo -9 8)`?_

> We try to think of the result of `(modulo x y)` as the `b` in 
  `x = a*y + b`.

> -9 = -1*8 + -1

> -9 = -2*8 + 7

> We use the first approach when computing remainder.  
  (Rule: The remainder has the same sign as the dividend.)

> We use the second approach when computing modulo.
  (Rule: The modulo value has the same sign as the divisor.)

> The circle model also shows this.  (Ha ha.  If you didn't come to 
  class, you can't see it.)

_Why are scaling and shifting not interchangable?_

> If you think about scaling a compound drawing, you want the relative
  positions of the parts to scale, rather than to have each part scale
  around its center.  (Another case in which the whiteboard shows more
  info than the eboard.)

_Can you write a procedure for something that makes a figure-eight-like
 shape?  (Two circles stacked on top of each other)_

> Design questions.  
  Tell me more about the shape - Are the two circles the same size, 
  or is the top one slightly smaller or ....?  
  What inputs will I want?  

> Answers: Two identical size circles.  Name it "eight".  Inputs will
  be radius, color, location (of center)

> Strategy: Multiple steps.  First we'll make a small figure eight at
  the origin.  We do that by shifting one copy of the unit circle up
  half its height and one copy of the unit circle down half its height.

        (drawing-group (vshift-drawing -0.5 drawing-unit-circle)
                       (vshift-drawing 0.5 drawing-unit-circle))

> Next step: Scale it.  (We generally like to scale before shifting, but
  sometimes small shifts, like those above, are good.)

        (scale-drawing (* 2 radius) ...)

> Shift it over

        (hshift-drawing 
         center-col
         (vshift-drawing
          center-row
          ...))

> Put in the "it's a procedure" information

> Putting it all together

       (define figure-eight
         (lambda (radius center-col center-row)
           (hshift-drawing
            center-col
            (vshift-drawing
             center-row
             (scale-drawing 
              (* 2 radius)
              (drawing-group (vshift-drawing -0.5 drawing-unit-circle)
                             (vshift-drawing 0.5 drawing-unit-circle)))))))

> Important lesson: Break it up into smaller parts.

> Lesson two: Sometimes you want to shift before scaling.  (And then
  shift again.)

> Lesson three: Work around the origin as a starting point.

_How would you design this differently if you were to have the top and
 bottom circles different sizes?_

> I might use the "inflection point" (probably needs a better name), rather
  than the center.  (But maybe left and top.)

> I'd take two radii instead of one.

> I'd expect more work.

_On the homework, please explain what you want for center-peg._

> See the following example

        (define peg-one (circle 50 20 30 "red")) 
        ; red circle, radius 50, eetc.
        ; the circle procedure comes from exercise 4 on the procs lab
        (define hole-one (circle 100 90 80 "green"))
        ; green circle, radius 100, etc.
        (define combo (center-peg peg-one hole-one))

        ; red circle, of radius 50, centered at (90,80), put on top
        ; of a green circle of radius 100, also centered at (90,80)

> You should be able to achieve this with shifting and grouping.

My Questions
------------

Sample Quiz Questions
---------------------

### Question type one: "Draw the picture"

Consider the following sequence of definitions

        (define d1 (hshift-drawing 50 drawing-unit-circle))
        (define d2 (hshift-drawing 20 drawing-unit-square))
        (define d3 (scale-drawing 5 (drawing-group d1 d2)))
        (recolor-drawing d2 "red")
        (define d4 (scale-drawing 20 d1))
        (image-show (drawing->image (drawing-group d3 d4) 100 50))

Sketch the result

* Yes, we'll do something more sensible than that.
* Yes, we are often tricky and ask you to draw things that include off-canvas
  portions (which you should not draw)

### Question type two: "Compute this value"

The "simple geometric center" of a drawing is the point horizontally
midway between the left edge and the right edge of the drawing, and
vertically midway between the top edge and the bottom edge of the
drawing.  Recall that there is no `drawing-bottom` or `drawing-right`
procedure.  Sketch the code you would use to find the x coordinate of
the center of drawing `my-drawing`.  (You don't know the definition of
that drawing.)

    (define center-x
      (+ (/ (drawing-width my-drawing) 2)
         (drawing-left my-drawing)))
