From: Lyman S. Taylor
Subject: Re: dictionary in lisp
Date: 
Message-ID: <6mosal$qjm@pravda.cc.gatech.edu>
In article <······················@theta.medizin.uni-ulm.de>,
kp gores <·····@sip.medizin.uni-ulm.de> wrote:
>hello,
>
>i try to implement a very simple dictionary in lisp.
>it should work like
>  (dict-look-up word)
.....
>i tried to put my words in a hash-table dict
>problem: hash-tables want sysmbols as keys.

   Not really.  Anything that is EQL would serve as key using the defaults.  
   The default "test predicate" for a hash table is EQL (as is typical
   for just about all language standard functions that require use of some 
   sort of equality test.) which will NOT equate strings.   However, EQUAL 
   and EQUALP will. 

    (eql "the-key"  "the-key")  ==>  NIL 
    (equal  "the-key" "the-key") ==>  T 
    (equalp "the-key" "the-key") ==>  T 
    (equalp "the-key" "THE-key") ===> T   ;; ignores case.... if desired...

>Q:       is there a way to make (setf (gethash "bla" dict) attribute-list )
>work?

    (setf dict  (make-hash-table :test #'equal ) )

    (setf (gethash "bla" dict )  '( foo bar baz ) )   ==>  ( FOO BAR BAZ) 

    (gethash "bla" dict )   ==>  ( FOO BAR BAZ )  T 

    (gethash "baz" dict 'not-found)  ==>  NOT-FOUND NIL 


     
-- 
Lyman S. Taylor           Comment by a professor observing two students 
(·····@cc.gatech.edu)     unconscious at their keyboards:
				"That's the trouble with graduate students.
				 Every couple of days, they fall asleep."