Re: hash-table-get problem?

From: <kanderso_at_BBN.COM>
Date: Wed, 07 Jun 95 20:14:46 -0400

  From: Sarah Officer <officers_at_nemesis.tucson.saic.com>
  Subject: hash-table-get problem?
  To: stk_at_kaolin.unice.fr
  Date: Wed, 7 Jun 1995 15:46:43 -0700 (MST)
  X-Mailer: ELM [version 2.4 PL21]
  Content-Type: text
  Content-Length: 755
  X-Mailing-List: <stk_at_kaolin.unice.fr> archive/latest/681
  X-Loop: stk_at_kaolin.unice.fr
  Precedence: list
  
  I am having difficulty retrieving a value from a hash table when the
  key is a string. It looks like the key is in the table, and I can retrieve
  it using hash-table-map or hash-table->list. Have I made a mistake?
  
The current implemnetation of hash tables only use a test of eq?. So, you
can only look up things that are eq?. Since

(eq? "sad" "sad") -> #f

you can't hash on strings directly, darn. What i do is turn them into
symbols as early as possible and compare symbols which are eq?.

;;; Interned strings are symbols since there is no builtin way to hash strings.
(define (intern-string string) (string->symbol string))

You could use another hash table to convert back from symbols to strings if
you need to, i don't.

Perhaps SLIB has a mre general solution.

k
Received on Thu Jun 08 1995 - 02:24:51 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST