[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hash tables
> From: "Paul A. Steckler" <steck@cs.rice.edu>
> Cc: "Plt-Scheme@Fast. Cs. Utah. Edu" <plt-scheme@fast.cs.utah.edu>
> Date: Thu, 8 Feb 2001 17:44:06 -0600
> Content-Type: text/plain;
> charset="iso-8859-1"
> X-Priority: 3 (Normal)
> X-MSMail-Priority: Normal
> Importance: Normal
> X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
>
> >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
>
OK, I get it now. I was confused by the error message/exception system
since I was using this interactively (my fault). Actually, symbols *are*
what I want, but I wanted to know the logic behind it.
Thanks,
Mike