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
Sketch or describe the final image that results from evaluating the following series of Scheme expressions. Your answer should clearly indicate the color, size, and position of each shape.
(define d1 (scale-drawing 20 drawing-unit-circle))
(define d2 (hshift-drawing 30 d1))
(recolor-drawing "red" d1)
(recolor-drawing "blue " d2)
(image-show (drawing->image (drawing-group d1 d2) 50 50))
At times, it is useful to find the center of a drawing. The center of a square, rectangle, circle, or ellipsoid is a point whose x coordinate is midway between the left edge and the right edge, and whose y coordinate is halfway between the top edge and bottom edge. There are many possible definitions of the center of a compound drawing; but the "halfway" rule works as a starting approach. Write a procedure, (drawing-center-x drawing), that returns the x coordinate of the center of a drawing, using the halfway rule. For example,
> (drawing-type my-cool-drawing)
'group
> (drawing-left my-cool-drawing)
10
> (drawing-width my-cool-drawing)
40
> (drawing-center-x my-cool-drawing)
30 ; The left edge is 10, the right is 50 (10 + 40)
> (drawing-left small-square)
0
> (drawing-width small-square)
1
> (drawing-center-x (drawing-group my-cool-drawing small-square))
25 ; The left edge is 0, the right edge is fifty
Finish the definition below
(define drawing-center-x
I was talking to a student about combinatorics and noted that CS and math share a characteristic that for some problems, you need a moment of insight. We know that you are just developing skills as problem solvers, and try to lead you to that insight. We also try to help you develop general processes.
With that said, let's consider two key ideas that might help you solve the neighbor problems.
We'll start with a circle of radius 40, centered at 120,80.
(classify-triangle 1 1 9) ; not a triangle, should get an error
(classify-triangel 2 3 2) ; should be isosceles