<HTML>
<HEAD>
<TITLE>iterating over a hash table</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:10pt'>Dear All,<BR>
<BR>
In the s-7 documentation, it says that a hash-table is a vector of alists and can be iterated over by vector-ref.<BR>
<BR>
In the following code (vector-ref table 1) throws a wrong-type-arg and I cannot figure out how to iterate over the table:<BR>
<BR>
---------------------------<BR>
<BR>
(define (entropy list)<BR>
&nbsp;&nbsp;&nbsp;(let ((table (make-hash-table))) <BR>
&nbsp;&nbsp;&nbsp;&nbsp;(loop for e in list <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do (if (table e) <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(set! (table e) (+ (table e) 1))<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(begin (set! (table e) 1))))<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(vector-ref table 1)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;))<BR>
<BR>
(entropy '(0 1 0 0 1 0))<BR>
<BR>
--------------------<BR>
<BR>
Any help will be much appreciated.<BR>
<BR>
Best,<BR>
<BR>
Mike</SPAN></FONT>
</BODY>
</HTML>