Functional Problem Solving (CSC 151 2014F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Rubric] - [Calendar]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Readings]
Reference: [Setup] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2014S)] [Weinman (2014F)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Issue Tracker (Course)]
Overview
assoc returns either an entry (row) or #f. In most cases
in which we call assoc, we want to do something to the entry or
return a default value for #f.lookup-and-process.Given an entry of the form ("red" 128 0 0 "reddish"), to build an
IRGB color, extract three components and call irgb on them. How
would we write this in Scheme?
(lambda (val)
(irgb-list->irgb (list-take (list-drop VAL 1) 3)))
Problem 2
(define strnum? (either string? number?)) (strnum? 'a)
f
(strnum? 3+4i)
t
(all number? (list 1 2 3 4))
t
(all number? (list 1 2 3 "sam" 4))
f
(all (lambda (val) (or (number? val) (string? val))) (list 1 2 4 "sam" 5))
t
(all (either number? string?) (list 1 2 3 4 "sam" 5))
t
(either number? string?)
We're drawing/selecting polygons with turtles. We realize that in order to get it to scale we would have to change the angels of our polygons so that they would no longer follow the (/ 360 sides) formula. What should we do?
Note that you would also have to change the length of each side. But both figuring out the angles and figuring out the side length is not reasonable. Hence, I am comfortable as long as your scaling works within the same aspect ratio, even if it does not work with different aspect ratios. (E.g., if the image goes from 100x100 to 200x200 or from 100x200 to 200x400, the turtle portions should scale correctly, but if it goes from 100x100 to 200x100 or 100x200, then the turtle portions do not need to scale correctly.) I'd recommend that you base your side length on either the minimum, maximum, or average of the dimensions of the image.
What about image-compute-pixels?
Now called
image-recompute!(image-recompute! image (lambda (x y) color))Also
image-redo!(image-redo! image (lambda (x y color) newcolor))Both should work on only what's selected.
Didn't you promise us code that would select based on a turtle?
Yes. And I sent it to you a while ago.
Two minutes with your partner
_Could you go over vector-sorted??