>>>>> "B" == Ben Tilly <ben_tilly / hotmail.com> writes:

 ruby version

B>   def hash (string)
B>     hash_val = 0
B>     for byte in string.each_byte do
B>       hash_val = 33*hash_val + byte
                    ^^
                    997
B>     end
B>     hash_val += hash_val/32
B>   end

 ruby can use the hash function given in the Dragon Book (compiled with
 -DHASH_ELFHASH), perl hash function (compiled with -DHASH_PERL) or it's
 own hash function.

 On /usr/share/dict/words the ruby hash function give less collisions
 than the perl hash function. Compile ruby with -DHASH_LOG to know the
 number of collisions.



Guy Decoux