Warning! You are being recorded (and transcribed).
Approximate overview
Academic/Scholarly
Cultural
Peer
Wellness
Misc
CHANGES.rkt file (summarizes your changes).(+ c (* r w)) in
the vector.(set-column! pixels width height c color)(set-row! pixels width height r color).Is there any way to make tables with more than one value for each key? Reading hints at it but doesn’t share how.
You could associate a list, vector, or hash table with each key.
> (define classes (make-hash))
> (hash-set! classes "SamR" (list "CSC-151-01" "CSC-207-02"))
> (hash-set! classes "Maddy" (list "CSC-151-01" "GWS-395-01" "JPN-495-11"))
Can “hash-ref” refer to the first element when given the second element as an input?
Unfortunately,
hash-refonly looks things up using the first element. If you really need to look things up by the reverse, you can make a new hash table that swaps the key and value. (I think we’ll do that in lab.)
How comparatively fast are hash-tables compared to linear search of a list in scheme?
In general, hash tables are much faster than searching a list of key/value pairs.
Why a hash table? Why not just a very large excel spreadsheet or something similar?
Because we want to process information quickly within the application. Communicating with an external application, such as Excel, will be expensive.
Note that we can save an Excel table as a
.csvfile and then load it into a hash table, and we can save a hash table as a.csvfile and load it into Excel.
Can we please start the lab?
Yes.
What’s an alpha channel?
How transparent or opaque the color/pixel is. (0 is “completely transparent” 255 is “completely opaque”).
This looks like so much fun. You must really care about us to give us such a great assignment!
Yes.
If you cared about us, you’d give us less work.
Really? I think you have that backwards. In any case, you now only need to do one of Part Three or Part Four for an M.
Yay! We get almost 45 minutes to do the lab.
Why is it called a hash table?
The term “hash” generally means “to chop up and mix together”. In the CS world, a “hash function” converts a value to an integer in such a way that (a) the same value always hashes to the same integer and (b) different values are unlikely to hash to the same integer.
Hash tables use hash functions and the remainder function to convert keys to indices in a (hidden) vector.
Is there a difference between hash-set! (with an exclamation point)
and hash-set (no exclamation point)?
Yes.
hash-set!changes a mutable hash table, either adding a key/value pair or replacing a key/value pair.
In contrast,
hash-settakes an immutable hash table as an input and creates a new immutable hash table (either adding a key/value pair or replacing a key/value pair).
Note: Building a new hash table is expensive!
Note: Since
hash-setandhash-removecreate new hash tables, they do not change the original hash table. It’s like if we had define a color,fave, and wrote(rgb-darker fave): We get a new color, butfaveis still the same.
In general, procedures that end with a bang (!) change their parameter (or something) and those that don’t end with a bang don’t.
Why do you say “bang” instead of “exclamation mark”?
Syllables. One vs. five.
What will Friday’s quiz look like?
That’s a great question.
Here’s our sample problem:
https://rebelsky.cs.grinnell.edu/Courses/CSC151/2024Sp/las/dictionaries.html
I like exercises 6 and 7 on this lab.
You know the drill
; MADDY SAID THAT I CAN STOP HERE. SAM AGREES.