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
What's the difference between a drawing and an image?
A drawing is a conceptual thing; it's a collection of colored ellipses and rectangles. An image, in contrast, is a reference to GIMP's rendering of something visual.
How many tests is enough?
Make sure that you cover all the cases, but each test can cover multiple cases. I would guess that ten different tests would suffice.
Getting the rectangles on top of the image is challenging. Any hints?
See the exam for hints.
_What's the relationship between hshift-drawing and drawing-hshift.
It's just the order of parameters.
(hshift-drawing AMT DRAWING)vs.(drawing-hshift DRAWING AMT). It's a matter of taste which you use.
Should we show you our experiments?
Yes.
Copy from the interactions pane. Paste into the definition pane. Select. Then comment out with semicolons (under the Racket menu).
Is there a procedure for finding the center of a shape?
Yes.
http://www.cs.grinnell.edu/~rebelsky/Courses/CSC151/2015S/labs/rackunit-drawings-lab.html
http://www.cs.grinnell.edu/~rebelsky/Courses/CSC151/2015S/eboards.am/extra.03.html
Can we give you multiple versions of a procedure in the hope that you will find one more to your liking?
If you indicate that the less correct ones are incorrect, yes.
Problem 1: Find the difference between a number and the square of its square root
(define error-root-squared
(lambda (number)
(- number (square (sqrt number)))))
(define error-root-squared
(lambda (x)
(- x (* (sqrt x) (sqrt x)))))
(define error-root-squared
(lambda (val)
(- val (expt (sqrt val) 2))))
display rarely.Problem 2: Given lots of weird code, figure out what it does.
(define circ
(hshift-drawing 0.5 (vshift-drawing 0.5 drawing-unit-circle)))
Given all of that, how would you describe circ?
(define shape (lambda (h v) (hshift-drawing h (vshift-drawing v (hscale-drawing h (vscale-drawing v circ))))))
Is shape a value or a procedure? It's a procedure - It has a lambda
Fourth action. Horizontally shift by 30. Results is an ellipse, centered at (45,105), top is 70, left is 30, height is 70, width is 30.
(define munge! (lambda (image) (drawing-render! (shape (* 1/3 (image-width image)) (* 1/3 (image-height image))) image)))
Procedure
(shape 200 150)