Warning! You are being recorded (and transcribed) (provided the technology is working correctly).
You should know the start-of-class algorithm
Approximate overview
Scholarly
Artistic/Cultural
Multicultural
Peer
Musical, theatric, sporting, academic, and similar events involving this section’s students are welcome.
Wellness
Misc
These do not earn tokens, but are worth your consideration.
Where do I submit mini-project 1?
I should have a location on Gradescope ready by Sunday night.
Can I take a makeup for last week’s quizzes?
The one labeled “Decomposition” makes up for the face quiz.
The one labled “Procedures” makes up for the evil building quiz.
Goals: Explore. Practice writing functions. Practice generalizing.
Which version of sub3 did people prefer?
It varied. (I also didn’t keep careful count.)
Is there a difference between #(rgb-darker %1) and rgb-darker?
Nope. The first as a longer way to write the second. You should only use cut when you’re filling in some parameters in an expression in order to create a procedure.
Can you go over Check 4 from the Transforming RGB colors reading
in more depth? I’d like a clearer explanation of why we use composition
here instead of lambda, and how the order of the procedures inside
o affects the result.
Sure. Here’s the question again.
a. Without using
lambda, write a procedure,(rgb-purpler c), that makescredder and bluer.
b. Without using
lambda, write a procedure,(rgb-much-darker c), that appliesrgb-darkerthree times in sequence toc.
Using lambda, we’d solve the first as
(define rgb-purpler (lambda (c) (rgb-bluer (rgb-redder c))))
Using
o, we’d solve the first as(define rgb-purpler (o rgb-bluer rgb-redder))
The composition solution to the first problem does not explictly name the parameter. That can be confusing at first. (You’ll get used to it.)
However, it’s much more concise.
It’s also a different way of thinking. We’re building new functions from old without worrying about a lot of cruft.
Don’t forget to explain how the order of functions affects the result.
It depends on the functions you’re using. Let’s look at this one from the self checks.
(define rgb-dl (o rgb-darker rgb-lighter))
Compare that to
(define rgb-ld (o rgb-lighter rgb-darker))
rgb-dlmakes the color lighter and then darker.
Remember that the functions are applied right-to-left.
Are there colors for which
(rgb-dl color)does not return the same color?
Sure. There are no colors that are lighter than white, so
rgb-lighterwill return white. Then we make it darker.
Since rgb-redder decreases the blue component and rgb-bluer decreases the
red component (and increases blue), won’t this have no effect on the components?
rgb-blueradds a large number to the blue component.rgb-reddersubtracts a smaller number. The net result is to increase the blue component (except at the boundaries).
Did the rgb-purpler and rgb-much-darker procedures need to
specifically include parameter c?
Nope. One of the key ideas of composition is that you don’t explicitly mention the parameters.
Can you explain in more details about the color transformations that are not that easy to build?
Some transformations are not naturally built from the existing procedures, such as “add two to red, subtract three from green, and double blue”.
Why doesn’t this work? #(o sub1 (o sub1(o sub1 %1)))
Because …
There are multiple
ocalls; we should be able to get by with one.
However,
(o sub1 (o sub1 sub1))would work.
We’d prefer
(o sub1 sub1 sub1)
The
%1will get filled in. We then try to composesub1and the thing that is filled in. We compose only functions. The intent was to fill in a number. You can’t compose a function and a number.
I still dont quite understand cutting method.
skipped
The primary idea is that we are “cutting” some values out of an expression, leaving room to fill them in.
For example
(string-append "this" " " "and" " " "that")would give you “this and that”.
To cut out the middle value, making it a parameter, we’d write something like
(define fun1 #("this" " " %1 " " "that")).
That creates a procedure that fills in the middle word.
(fun1 "or")-> “this or that”
(fun1 "but not")-> “this but not that”
If we cut out the end values to make them parameters, we’d write something like
(define fun2 #(%1 " " %1 " " "that"))
Please reload the schedule page before begining the lab.
Make sure that you’re doing “Transforming RGB colors”. If not, reload the schedule page and try again.
Whoops! Not a lot of time. We’ll cope.
Don’t turn anything in today. Plan to do meet with the same partner on Monday to finish this lab and do the next one. (Same place, same partner.)
We will distribute the tracing quiz.
When you are done, give it to Sam and take any makeup quizzes you want.
When you are done, give them to Sam and leave.
Sam will be here until about 4:30 p.m.
Have a great weekend!