Functional Problem Solving (CSC 151 2015F) : EBoards

CSC151.01 2015F, Class 10: Side Effects: Output and Input


Overview

Preliminaries

Admin

Upcoming Work

Extra Credit Opportunities

Academic

Peer Support

Quiz 2 Returned

Problem 1

We expected something like the following.

(define cube (section expt <> 3))

Some of you tried to use *, but each <> is a separate input.

Problem 2a

(define fave (irgb 250 0 42))
(irgb-complement fave)
> (irgb->string fave)
"250/0/42"

This problem was to remind you that irgb-complement does not change fave. Rather, it computes a new color. That's similar to

(define num 5)
(square num)
> num
5

The behavior of irgb-complement and square contrasts a bit with the kinds of procedures we're playing with today.

Problem 2b

(define fave (irgb 250 0 42))
(define fave2 (irgb-darker (irgb-lighter fave)))
> (irgb->string fave2)
"239/0/42"

An important point from the labs was that irgb-lighter and irgb-darker cap when you reach the extreme values (0 and 255). So the red component of (irgb-lighter fave) is 255. When you subtract 16, we end up with 239.

Homework Questions

For a latter problem, we've written irgb-rotate-hue to take two parameters but image-variant expects a procedure that takes only one parameter. What do we do?

You want to write (image-variant IMAGE proc); you can't write (image-variant IMAGE irgb-rotate-hue). (Yes, I've just restated your question.)

You should know how to turn a two-parameter procedure into a one-parameter procedure by filling in one of the parameters with a value.

If we have two answers that we think are equally good, should we provide both?

Sure.

Do you want examples from interactions, too?

Yes. Copy and paste into definitions pane, and then use "comment out with semicolons."

For the extra credit, what should we do when the chroma is 0?

You should handle that case appropriately, giving a hue of 0.

And you can (should) do that without using an if expression.

The hsv procedure didn't work.

Make sure to run /home/rebelsky/bin/csc151-update again.

Computers are sentient and malicious.

Try asking a tutor.

Lab