Functional Problem Solving (CSC 151 2013F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning] [Grading]
Current: [Assignment] [EBoard] [Lab] [Outline] [Partners] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Setup] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2010F)] [Weinman (2012F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)]
Overview
Admin
Preparation for Quiz (and other discussion items)
I have a bit of code to show you that I hope resolves some recent questions. Then I'll give you ten minutes for additonal questions.
#lang racket
(require gigls/unsafe)
;;; File:
;;; sample.rkt
;;; Author:
;;; Samuel A. Rebelsky
;;; Summary:
;; A quick sample to illustrate a variety of points about drawings.
;;; Procedure:
;;; bigred
;;; Parameters:
;;; drawing, a drawing
;;; Purpose:
;;; To confuse students
;;; Produces:
;;; A drawing
;;; Props:
;;; Taken from a clicker question designed by SR and JD
(define bigred
(lambda (drawing)
(drawing-recolor drawing "red")
(drawing-scale drawing 10)))
;;; Procedure:
;;; preview
;;; Parameters:
;;; d, a drawing
;;; Purpose:
;;; preview the drawing in a new window
;;; Produces:
;;; img, the id of the preview image
;;; Preconditions:
;;; (drawing-right d) >= 1
;;; (drawing-bottom d) >= 1
;;; Postconditions:
;;; img contains a rendering of d
(define preview
(lambda (d)
(image-show (drawing->image d (drawing-right d) (drawing-bottom d)))))
;;; Value
;;; d1, a sample drawing
;;; Type:
;;; drawing
;;; Contents:
;;; A black, 50x50 circle centered at (25,25)
(define d1
(drawing-hshift
(drawing-vshift
(drawing-scale drawing-unit-circle 50)
25)
25))
;;; Value:
;;; d2
;;; Type:
;;; drawing
;;; Contents:
;;; A purple 50x50 circle, centered at (75,75)
(define d2
(drawing-hshift
(drawing-vshift
(drawing-scale
(drawing-recolor drawing-unit-circle "purple")
50)
75)
75))
;;; Value:
;;; d3
;;; Type:
;;; drawing
;;; Contents:
;;; A green rectangle
(define d3
(drawing-hshift
(drawing-vshift
(drawing-scale
(drawing-recolor
drawing-unit-square
"green")
30)
20)
80))
;;; Value:
;;; scene
;;; Type:
;;; drawing
;;; Summary:
;;; A simple scene
(define scene
(drawing-group d1 d2 d3))
;;; Procedure:
;;; drawing-munge
;;; Parameters:
;;; drawing, a drawing
;;; Purpose:
;;; Create a new drawing, based on the original drawing
;;; Produces:
;;; new-drawing, a drawing
(define drawing-munge
(lambda (d)
(drawing-recolor (drawing-scale d 1.1) "blue")))
Disappearing values
3 + (4*5)
Just as intermediate values in a calculation disappear, so do intermedia drawings.
Behind the scenes: Procedures
When does order matter?
What's the difference between drawing-bottom and drawing-height
Where should your detail be: In the parameters or the pre/post?
Can we derive immense satisfaction from watching SamR screw up while trying to do relatively easy things in DrRacket/Gimp?
Quiz
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning] [Grading]
Current: [Assignment] [EBoard] [Lab] [Outline] [Partners] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Setup] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2010F)] [Weinman (2012F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)]
Samuel A. Rebelsky, rebelsky@grinnell.edu
Copyright (c) 2007-2013 Janet Davis, Samuel A. Rebelsky, and Jerod Weinman. (Selected materials are copyright by John David Stone or Henry Walker and are used with permission.)

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this
license, visit http://creativecommons.org/licenses/by-nc/3.0/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.