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
How do I copy and paste from images?
;;; Procedure:
;;; image-copy-paste-block!
;;; Parameters:
;;; source, an image id
;;; source-col, an integer
;;; source-row, an integer
;;; target, an image id
;;; target-col, an integer
;;; target-row, an integer
;;; width, an integer
;;; height, an integer
;;; Purpose:
;;; Copy a width-by-height block from source to target, with the
;;; top-left corner of each block as specified.
;;; Produces:
;;; [Nothing; called for the side effect.]
;;; Problems:
;;; Does not do well with improper column/row pairs (e.g., those
;;; outside the bounds of the image).
I'm having trouble with problem 2. Any hints?
(visualize-transforms (color->irgb "pink") (list (lambda (irgb-color) irgb-color) irgb-darker (o irgb-darker irgb-darker) (o irgb-darker irgb-darker irgb-darker) (o irgb-darker irgb-darker irgb-darker irgb-darker)) 5)
Identify parameters: 1. Integer-encoded RGB color; 2. List of procs. "transformations" - given a color, produce a (potentially) new color. 3. The number of transformations.
You want to make a list of colors, and then use
visualize-colors.How do you make the list of colors? Well, given a list of the form
'(t1 t2 t3 t4 t5), you want to make the list that contains the values(t1 irgb-color),(t2 irgb-color),(t3 irgb-color),(t4 irgb-color), and(t5 irgb-color). Given one list, you make another list with an appropriate call tomap.
(map ______ transformations).
How do you write post-conditions for a procedure that returns a procedure?
Option 1:
;;; Produces:
;;; proc, a procedure
;;; ...
;;; Postconditions:
;;; proc has the form (proc param1 param2) where param1 is a
;;; an integer and param2 is an image id. proc computes ...
Option 2:
;;; Produces:
;;; proc, a procedure from integers and image ids to image ids.
;;; ...
;;; Postconditions:
;;; (proc param1 param2) has the value ...
Option 3:
;;; Produces:
;;; proc, a procedure
;;; ...
;;; Postconditions:
;;; proc meets the following specifications
;;; Parameters:
;;; param1, an integer
;;; param2, an image id
;;; Purpose:
;;; ...
;;; Produces:
;;; image, an image id
;;; Preconditions:
;;; [No additional]
;;; Postconditions:
;;; ...
In Problem 4 on Assignment 5, does "a simple shape of your choice" mean that the user can customize a shape, or that the programmer decides what shape to use?
I was assuming that you, in implementing the procedure, would decide what the shape would be.
You learned three new mechanisms for conditional evaluation:
if, when, and cond. What are the similarities and differences
between them? Why might you use one over another?
Many Scheme programmers consider and and or additional mechanisms
for conditional evaluation. Why?
The reading was intended partially as review and partially to introduce new ideas. What new things did you learn about anonymous procedures?
l-s within compose.