Approximate overview
As I reviewed the reading responses on vectors, I noted that there
was some confusion on vector-set!. The vector-set! procedure,
like most procedures that end in an exclamation point, returns nothing
(or at least nothing you see). You call it only for the side effect of
changing the vector.
You’ll discover that hash-set! and hash-remove! also don’t seem to
return anything.
Note: In reality, these procedures return a special value, #<void>.
Racket generally doesn’t display void values, unless they appear nested
in other values.
Can you explain the difference between immutable and mutable hash tables?
You’ll find that it’s much like vectors: You can add and change values in mutable hash tables, but you can’t do so in immutable hash tables. We’ll explore those differences in lab.
Can you have multiple authors for a single book?
You could choose to associate a list of authors with a title, rather than a single author.
For example,
(hash-set! book-authors "Goodnight Moon"
'("Margaret Wise Brown"
"Clement Hurd"))
Can you keep doing that?
Sure.
Are office hours still online?
Yup. The surge of the new Omicron variant suggests they should be.
Can I meet with you outside of office hours?
Certainly. Propose a time using the Outlook/Teams scheduler.
Will there be an opportunity for a second redo of MP1 and MP2?
Yup. It will cost two tokens to do a second redo.
Have you updated tokens recently?
I will tonight. If all goes well, they’ll also be part of the grade sheet. (I need to update the grade sheet software to include them.)
hash-tables.rktWhy doesn’t hash-remove! issue an error when the key is not present?
Because it still achieves your goal: Afterwards, the key is not present.
Note: hash-set! changes a mutable hash table, while hash-set
returns a new immutable hash table. (Similar for hash-remove! and
hash-remove.)
For the Jane Eyre problem, use something like
(define sample-words
(file->words "hash-tables.rkt"))
Note: If you look at the value returned by hash-set! (or almost
any exclamation procedure, you’ll find that it’s #void).
Please finish the lab on your own. (Question 7 will be important for future activities.) You can work with your partner or you can do it separately.