[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: hash tables



>It appears that it is not possible to use a string as a key in mzscheme's
>hash tables.  Is this correct?  I've been able to use symbols and numbers
>as keys but not strings or immutable strings; why is that?  Also, it would
>be nice if an error was raised when an invalid key is used, as opposed to
>finding out later that there is nothing stored at that key location.

Two Scheme keys hash to the same value iff they are eq?.
Two strings containing the same characters are not
eq?.  The *same* string can be used as a hash key,
but that's rarely what you want.

You can convert your strings to symbols to use them
as hash keys.

The procedure hash-table-get does raise an exception when no value 
is found.

-- Paul