Warning! You are being recorded (and transcribed) (provided the technology is working correctly).
Today’s start-of-class procedure
Note: If you need to sit in a particular area of the classroom, let me know and we’ll work things out in the future.
Approximate overview
Scholarly
Artistic
Multicultural
Peer
Musical, theatric, sporting, and academic events involving this section’s students are welcome.
Pride week!
Wellness
Misc
These do not earn tokens, but are worth your consideration.
Why do some of my assignments say “Submitted” and some say “Ungraded”?
“Submitted” means that you’ve submitted it but I haven’t started grading the assignment.
“Ungraded” means that you’ve submitted it, and I’ve started grading the assignment, but I haven’t gotten to yours yet.
Note that “I” can also mean “the graders”.
Though I have written my own code, I have used a library created by Grinnell CS. Is it necessary to cite in this case, and if so, how do I properly cite the section of the csc151 library that I used?
If you are importing a library (in our case, with
(require csc151)
), you need not provide additional citations.
How do we go back and edit code?
I assume you’re asking about the interactions pane. On Linux and Windows boxes, it’s usually Ctrl-UpArrow and Ctrl-DownArrow. On the Mac, it’s Esc-P (previous) and Esc-N (next).
Why won’t DrRacket load the csc151 library on my computer?
I’m not sure.
Can DrRacket’s image model use hexadecimal color?
If you mean the hex for RGB, then yes. You need to use something like
(hex->rgb "AA00B7")
.
Why does the name of the color have to be in quotation marks, and how does DrRacket know that its a color not a string?
Actually, it’s a string that names a color. If it weren’t in quotation marks, DrRacket would think that it’s something we’ve named with
define
.
I don’t really understand the top-down design, particularly what the purpose of using ??? just to come back and replace it is.
We’ll think about this in terms of the PB&J sandwich.
Get bread. Spread peanut butter on bread. Add bananas. Eat.
Open jar of peanut butter. Remove spoonful of peanut butter. Add to bread. Spread with knifer.
Grab jar with lid facing upward using your dominant hand. Grab lid of jar with other hand. …
History suggests that this is a good way of thinking about problem solving.
Can we go over the specific parts of a procedures
Certainly.
A procedure (subroutine, functions, methods) is a named collection of code that takes input.
Three things to think about in how we write procedures in almost any programming language.
- The name. How will we refer to the procedure in the future?
- The inputs. How will we refer to the inputs in the body of the procedure? (In some languages, we give both names and types (integer, string, color, …) to inputs; in Scheme, we only give names.)
- The body: What the procedure actually does/computes.
In Scheme, we write
(define NAME
(lambda (INPUTS)
BODY))
Suppose we want a procedure that surrounds an image with semi-circles.
(define surround-with-semi-circles
(lambda (img color)
(beside (wedge (* 1/2 (image-height img)) color 180)
img
(wedge (* 1/2 (image-height img)) color 180))))
FIXED:
(define surround-with-semi-circles
(lambda (img color)
(beside (rotate (solid-wedge (* 1/2 (image-height img)) 180 color) 90)
img
(rotate (solid-wedge (* 1/2 (image-height img)) 180 color) -90))))
I know the text mentioned we will cover lambda without define eventually but I would genuinely love to know why the idea of it being “anonymous” is so powerful.
We should talk about it next week. (Perhaps even this week.) It’s more than just the lambda.
For the check 2 in the last reading, when I wrote the code (solid-rectangle 40 20 "color")
, it did not work. Why are we not supposed to use “” with color?
The quotation marks mean “Take it verbatim” rather than “treat this as an input to the method”. There’s no color named “color”, so it gives an error.
Make sure that you’re doing the lab called “procedures”. You may have to refresh your schedule.
Save save save save save.