Functional Problem Solving (CSC 151 2015S) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Taking Notes] [Rubric] - [Calendar]
Current: [Assignment] [EBoard am] [EBoard pm] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards am] [EBoards pm] [Labs] [Outlines] [Readings] - [Examples] [Handouts]
Reference: [Setup] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2014F)] [Weinman (2014F)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Book Office Hours] - [Issue Tracker (Course)]
Overview
smiley procedure using the 6P format.Quiz 1: You all had a better process for getting people to be with matching cards. Why didn't you use it?
Quiz 2, Problem 1.
(define d0 (recolor-drawing "blue" drawing-unit-square))
(define d1 (scale-drawing 30 d0))
(define d2 (hshift-drawing 20 d1))
(recolor-drawing "red" d1)
(scale-drawing 1.5 d2)
(image-show (drawing->image (drawing-group d1 d2) 50 50))
Two minutes: Discuss with partner. Then Sam has a series of questions.
How big is the image/canvas we draw?
50 by 50.
After the first expression, (define d0 ...), what is the value of d0?
A 1x1 square, centered at (0,0), colored blue. Left boundary is -0.5, top boundary is -0.5, right boundary is 0.5, bottom boundary is 0.5.
_After the second expression, (define d1 ...), what is the value of d0?
Answer 1: I don't know.
Answer 2:
d0stays the same, we're just defining a new square which is a bigger version ofd0.Answer 3: The side length of
d0becomes 30, which means that we have A 30x30 square, centered at (0,0), colored blue. Left boundary is -15.0 top boundary is -15.0, right boundary is 15.0, bottom boundary is 15.0.
How would we figure out which is correct?
Try it!
Ask someone who might know.
Read your notes (or the reading, or the reference pages, or ...)
And our conclusion is?
Answer 2 is correct.
All of the drawing manipulation procedures create a new drawing rather than modifing the existing drawing.
(define x 2)
(square x)
x
_After the second expression, (define d1 ...), what is the value of d1?
A 30x30 square, centered at (0,0), colored blue. Left boundary is -15.0 top boundary is -15.0, right boundary is 15.0, bottom boundary is 15.0.
_After the third expression, (define d2 ...), what is the value of d0?
Whatever it was before. Blue unit square, centered at (0,0).
_After the third expression, (define d2 ...), what is the value of d1?
Still a blue square 30x30 centered at (0,0).
_After the third expression, (define d2 ...), what is the value of d2?
A blue square 30x30 centered at (20,0), left boundary at 5, top boundary at -15.
_What is the value of the fourth expression, (recolor-drawing "red" d1)?
A red square centered at (0,0), of side length 30.
After the fourth expression, what is the value of d1?
The same thing it was before, blue square.
What is the value of the fifth expression, (scale-drawing 1.5 d2)?
A 45x45 blue square, centered at (30,0).
What does the final image look like?
For Problem 2 on Quiz 2, you need to know that we had procedures like
drawing-left, drawing-top, drawing-width.
Question for Sam: Can we change the definition of d0?
If it's defined in the definitions pane, no.
If it's defined in the interactions pane, yes.
;;; Procedure:
;;; max
;;; Parameters:
;;; val1, real
;;; val2, real
;;; Purpose:
;;; Find the largest of val1 and val2.
;;; Produces:
;;; larger-of-the-two, real
;;; Preconditions:
;;; Postconditions:
;;; larger-of-the-two = val1 or larger-of-the-two = val2
;;; larger-of-the-two >= val1
;;; larger-of-the-two >= val2
;;; Procedure:
;;; neighbor
;;; Parameters:
;;; drawing, a drawing
;;; Purpose:
;;; Make a copy of drawing, immediately to the right of drawing.
;;; Produces:
;;; greener-grass, another drawing
;;; Postconditions:
;;; (drawing-left greener-grass) = (drawing-right drawing)
;;; (drawing-width greener-grass) = (drawing-width drawing)
;;; (drawing-height greener-grass) = (drawing-height drawing)
;;; (drawing-top greener-grass) = (drawing-top drawing)
;;; greener-grass is the same type and colors as drawing.
;;;