Hi,
I wonder how the hash table computes the hash code when the key is a
list.
it seems not to use the content to compute hash code, but use the
pointer of cons. I am confused.
Regards,
Haiwei
* (setq a (make-hash-table))
Warning: Declaring A special.
#<EQL hash table, 0 entries {5819D7CD}>
* (gethash '(a b c) a)
NIL
NIL
* (eq (gethash '(a b c) a) (gethash '(a b c) a))
T
* (setf (gethash '(a b c) a) 1)
1
* (setf (gethash '(a b c) a) 2)
2
* :i a
:I
*
#<EQL hash table, 2 entries {5819D7CD}>
* (setf (gethash '(a b c) a) 2)
2
* :i a
:I
*
#<EQL hash table, 3 entries {5819D7CD}>
Haiwei wrote:
> Hi,
>
> I wonder how the hash table computes the hash code when the key is a
> list.
> it seems not to use the content to compute hash code, but use the
> pointer of cons. I am confused.
>
> Regards,
> Haiwei
>
> * (setq a (make-hash-table))
(setf a (make-hash-table :test 'equal)
>
> Warning: Declaring A special.
>
> #<EQL hash table, 0 entries {5819D7CD}>
> * (gethash '(a b c) a)
>
> NIL
> NIL
> * (eq (gethash '(a b c) a) (gethash '(a b c) a))
>
> T
> * (setf (gethash '(a b c) a) 1)
>
> 1
> * (setf (gethash '(a b c) a) 2)
>
> 2
> * :i a
>
> :I
> *
> #<EQL hash table, 2 entries {5819D7CD}>
> * (setf (gethash '(a b c) a) 2)
>
> 2
> * :i a
>
> :I
> *
> #<EQL hash table, 3 entries {5819D7CD}>
H> I wonder how the hash table computes the hash code when the key is a
H> list.
H> it seems not to use the content to compute hash code, but use the
H> pointer of cons. I am confused.
H> #<EQL hash table, 0 entries {5819D7CD}>
(EQL'(a b c) '(a b c)) => NIL