PLT Scheme provides basic, but useful and fast ways of manipulating
hashes. A hash table is used to store a collection of data values
associated with keys.
To create a hash table use make-hash-table, which receives two
optional arguments to create tables with weakly-held keys, and to use
different comparison procedures. We will discuss this variations
later, so for the time being something like:
(make-hash-table)
creates a new hash table. By default this table will compare keys
using eq?. If you want to use keys that need a stronger equality test (i.e., strings), you can provide make-hash-table with the argument equal:
(make-hash-table'equal)
In the following recipes we will discuss ways to manipulate our newly
created hash table.
Small comment: maybe we should avoid the use of the word "hash", since that's become a Perl term with lots of associations. Also, maybe we should have a breakdown of what Perl hashes are used for and how they map to different concepts and idioms in Scheme and PLT Scheme. (Someone who knows recent Perl versions better than I do would ideally volunteer...)
-- NeilVanDyke - 14 Jun 2004
I'd like to see some discussion of assoc lists vs. hashes. I always use assoc lists because it's convenient, what are the advantages of hashes over assq/assv/assoc?
-- GordonWeakliem - 17 Sep 2004