Functional Problem Solving (CSC 151 2016S) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Taking Notes] [Rubric]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Labs] [Outlines] [Readings] - [Examples] [Handouts]
Reference: [Setup] [Remote] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Curtsinger (2016S)] [Davis (2013F)] [Rebelsky (2015F)] [Weinman (2014F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Issue Tracker (Course)]
Overview
Pub Quiz Wednesday at 10, hosted by Neuro/Psych SEPC. You can eat food, or pay to participate in the quiz ($3/team).
Social Dance Workshop Tuesdays 7:00-8:00 in Bucksbaum Dance Studio
image-computeimage-variant
image-variant takes a function from colors to colorsimage-compute takes a function from positions to colors
> (define blend1
(lambda (col row)
(irgb (* 255 (/ col 200)) 0 0)))
> (image—show (image-compute blend1 200 200))
What do you think will this show?
> (define blend2
(lambda (x y)
(irgb (* 255 (/ x 200))
0
(- 255 (* 255 (/ x 200))))))
> (image-show (image-compute blend2 200 200))
What do you think will this show?
> (define blend3
(lambda (x y)
(irgb (remainder (*10 x) 256) 0 0)))
> (image-show (image-compute blend3 200 200))
What do you think will this show?
> (define blend4
(lambda (x y)
(irgb (abs (- 255 (remainder (* 10 x) (* 255 2))))
0
0)))
> (image-show (image-compute blend4 200 200))
What do you think it will show? * It will kind of be like the last one where it cycles? * It will cycle by going up first then back down. * Unlike the last one where it goes from a sharp turn from red to black, it’ll slowly go back from red to black again
> (define blend4
(lambda (x y)
(irgb (abs (- 255 (remainder (* 10 x) (* 255 2))))
(abs (- 255 (remainder (* 10 y) (* 255 2))))
0)))
We can do stuff other than cool blends.
> (define thing1
(lambda (x y)
(if (and (> x 50) (< x 100) (> y 50) (< y 100))
(irgb 255 0 0)
(irgb 0 0 255))))
What will this show?
> (define thing2
(lambda (x y)
(let ([num (remainder (truncate (/ x 20)) 3)])
(cond
[(= num 0)
(irgb 255 0 0)]
[(= num 1)
(irgb 0 255 0)]
[else
i (irgb 0 0 255)]))))
What will this show?
> (define thing3
(lambda (x y)
(let ([num (remainder (truncate (/ x 20)) 3)]
[comp (* 255 (/ y 200))])
(cond ((= num 0)
Writeup: Problem 3 (Class 22)