common lisp hashtabe syntax question

Joined
Apr 4, 2003
Messages
836
i need to add distinct pairs to a hashtable and associate a value with them.

let's say we have x, y, and z. each of {x,y} {x,z} {y,z} is what i need to store and associate a value with.

i have tried this:
Code:
(setf (gethash '('x . 'y) sometable) 1.2)

i have also tried
Code:
(setf (gethash '('x  'y) sometable) 1.2)

when i
Code:
(gethash '('x . 'y) sometable)

and when i
Code:
(gethash '('x 'y) sometable)

the result is the same. i get NIL. do you have any insight?

edit: is it possible that my insertion is inserting a LISP object '('x 'y) into the table and when i search for it with gethash that i am searching for another new LISP object that happens to have the same attributes? is this why i get NIL? if so, how do i step around this?
 
okay, i finally got it. my hypothesis in my edit was correct, so that means i was using the wrong type of test. the table works now with the creation of the table as such:

Code:
(setq sometable (make-hash-table :test 'equalp))
 
Back
Top