On Saturday, August 3, 2019 at 9:22:16 AM UTC+8, Jesse Wang wrote: > > Racket allows different types of keys in a single hash, so there must be a > hash function that works for different types(different primitive types), I > wonder how Racket implements this under the hood. > Also, If I want to implement a hash table which allows different types of > keys, how can I implement such a hash function in Racket? > > Thanks! >
It seems for functions like equal-hash-code and eq-hash-code, different primitive type have different rules for calculating the hash value, for example: > (equal-hash-code 123) 123 > (equal-hash-code '123) 123 > (equal-hash-code "123") 115049109349 > (equal-hash-code 123.0) 1432682342767248795 the result hash values are not uniformly distributed. If I want to turn the hash code into array index in a hash table, do I need to apply another uniform hash function such as md5 on the result of equal-hash-code? -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/eea3bd1a-7a4f-48fe-97e0-ba65738a7ae1%40googlegroups.com.