Functional Problem Solving (CSC 151 2014F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Rubric] - [Calendar]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Readings]
Reference: [Setup] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2014S)] [Weinman (2014F)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Issue Tracker (Course)]
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.
Consider "smaller-right-neighbor"
;;; Procedure:
;;; smaller-right-neighbor
;;; Parameters:
;;; drawing, a drawing
;;; Purpose:
;;; Create a smaller drawing, to the right of the original
;;; Produces:
;;; smaller, a drawing
;;; Preconditions:
;;; [No additional]
;;; Postconditions:
;;; (drawing-width smaller) = (* .75 (drawing-width drawing))
;;; (drawing-height smaller) = (* .75 (drawing-height drawing))
;;; (drawing-left smaller) = (drawing-right drawing)
;;; (drawing-top smaller) = (drawing-top drawing)
Details:
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))))))
drawing-unit-circle: black, diameter 1, center 0,0(hshift-drawing 1 ...): black, diameter 1, center 1,0(recolor-drawing "blue"...): blue, diameter 1, center 1,0(scale-drawing 100 ...): blue, diameter 100, center 100,0(vshift-drawing 100 ...): blue, diameter 100, center 100,100(hshift-drawing 100 ...): blue, diameter 100, center 200,100