Functional Problem Solving (CSC 151 2015F) : Outlines
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Taking Notes] [Rubric] [Remote Access]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Labs] [Outlines] [Readings] - [Examples] [Handouts]
Reference: [Setup] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Curtsinger (2015F)] [Davis (2013F)] [Rebelsky (2015S)] [Weinman (2014F)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Issue Tracker (Course)]
Held: Monday, 5 October 2015
Back to Outline 21 - Anonymous Procedures, Revisited. On to Outline 23 - Revisiting Lists.
Summary
We consider a simple approach to working with images - looping over the positions in an image and computing a new color based on positional information. We then explore some applications of this approach.
Related Pages
Overview
Administrivia
You are now at the point that you should be able to notate lists correctly. Please do so in the future.
The last problem caused trouble for many of you. It asked you to identify whether the parameter was a non-zero, even, integer.
even? on a non-integer,
so we better make sure that it's an integer before we call even?Here's one solution
(define non-zero-even?
(lambda (num)
(cond
[(not (integer? num))
#f]
[(not (even? num))
#f]
[(zero? num)
#f]
[else
#t])))
However, as ZS says, "If you find yourself explicitly writing #t and #f, you can probably simplify it."
(define non-zero-even?
(lambda (num)
(and (integer? num) (even? num) (not (zero? num)))))
image-compute modelimage-variant model, we built images with a starting
image and a function from colors to colors.(image-compute *function* *width* *height*)