Functional Problem Solving (CSC 151 2014F) : EBoards

CSC 151: Extra Session 2 (Thursday, 11 Sept. 2014)


Overview

Repeat
  Repeat
    You ask questions
    I attempt answers
  Until we run out of time or you run out of questions
  Repeat
    I ask questions
    You attempt answers
    I provide followup comments
  Until we run out of time or you start asking questions again
Until we run out of time

What's on the quiz tomorrow?

Are all quizzes on paper?

Tell me more about what you expect to see in postconditions.

What does drawing-group do?

Can you explain the following documentation?

;;; Procedure:
;;;   circle
;;; Parameters:
;;;   x, a real number
;;;   y, a real number
;;;   r, a positive real number
;;;   color, a color
;;; Purpose:
;;;   Creates a drawing of a circle of radius r, centered at (x,y).
;;; Produces:
;;;   drawing, a drawing
;;; Preconditions:
;;;   [No additional]
;;; Postconditions:
;;;   drawing is an ellipse.  That is (drawing-ellipse? drawing) holds.
;;;   (drawing-left drawing) = (- x r)
;;;   (drawing-top drawing) = (- y r)
;;;   (drawing-width drawing) = (* 2 r)
;;;   (drawing-height drawing) = (* 2 r)
;;;   (drawing-width drawing) = (drawing-height drawing)
;;;   (drawing-color drawing) = color

Can you give an example of something that would require preconditions?

;;; Procedure:
;;;   drawing->image
;;; Parameters:
;;;   drawing, a drawing
;;;   width, an integer
;;;   height, an integer
;;; Purpose:
;;;   Render the portion of the drawing that falls between (0,0) and
;;;   (width,height) on an image whose size is width-by-height.
;;; Produces:
;;;   rendering, an image
;;; Preconditions:
;;;   width and height are positive
;;;   Some part of the drawing falls between (0,0) and (width,height)
;;; Postconditions:
;;;   image contains a visual representation of the portion of the
;;;     drawing in the range (0,0) to (width,height)
;;;   (image-width rendering) = width
;;;   (image-height rendering) = height
;;;   rendering is not yet displayed on the screen

Can you discuss the relationship of scaling and shifting?

Followup question: It feels like you are scaling the image, not the drawing.

Sample quiz question: What do you get from each of the following?

(define circle1 (hshift-drawing 100 (vshift-drawing 100 (scale-drawing 100 (recolor-drawing "red" drawing-unit-circle)))))

(define circle2
  (recolor-drawing 
   "green"
   (hshift-drawing 
    1 
    circle1)))

(define circle3 
  (hshift-drawing 
   100
   (vshift-drawing 
    100
    (scale-drawing 
     100
     (recolor-drawing 
      "blue" 
      (hshift-drawing 1 drawing-unit-circle))))))