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 test 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.
How many tests should we include?
For the test suite problem (#5), I want to see all of your tests.
For the others, it's still probably nice to see your experiments, but not required.
Do we make our test suite specific to our implementation?
No. Test suites are intended to test any procedure that tries to meet the given requirements/expectations.
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.
First thing
(define circ
(hshift-drawing 0.5 (vshift-drawing 0.5 drawing-unit-circle)))
Telling the difference between values and procedures
(define sam 2)
(define prof-rebel (lambda (x) (- x 10)))
(define shape
(lambda (h v)
(hshift-drawing h
(vshift-drawing v
(hscale-drawing h
(vscale-drawing v
circ))))))
Last part
(define munge!
(lambda (image)
(drawing-render! (shape (* 1/3 (image-width image))
(* 1/3 (image-height image)))
image)))
* Procedure or value? Procedure * Parameters/inputs, image * Produces/output * Suppose I give it an image (say the 640x400 image we have on the screen). What's the first thing it does? Computes 1/3 of the width. Computes 1/3 of the height.