[racket-users] How to implement a hash function for different types?

2019-08-02 Thread Jesse Wang
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 implem

Re: [racket-users] How to implement a hash function for different types?

2019-08-02 Thread Justin Zamora
Racket doesn't implement hash tables using a hash function. If I recall correctly, it uses b-trees as the representation for a hash table. The Racket reference states that "Immutable hash tables actually provide O(log N) access and update. Since N is limited by the address space so that log N is l

Re: [racket-users] How to implement a hash function for different types?

2019-08-02 Thread Jon Zeppieri
On Fri, Aug 2, 2019 at 9:37 PM Justin Zamora wrote: > > Racket doesn't implement hash tables using a hash function. If I > recall correctly, it uses b-trees as the representation for a hash > table. The Racket reference states that "Immutable hash tables > actually provide O(log N) access and upd

Re: [racket-users] How to implement a hash function for different types?

2019-08-02 Thread Jesse Wang
On Saturday, August 3, 2019 at 9:52:28 AM UTC+8, Jon Zeppieri wrote: > > On Fri, Aug 2, 2019 at 9:37 PM Justin Zamora > wrote: > > > > Racket doesn't implement hash tables using a hash function. If I > > recall correctly, it uses b-trees as the representation for a hash > > table. The Racke

Re: [racket-users] How to implement a hash function for different types?

2019-08-02 Thread Jon Zeppieri
On Sat, Aug 3, 2019 at 12:52 AM Jesse Wang wrote: > > 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? > That wouldn't accomplish anything. The defining feature of a function is th

Re: [racket-users] How to implement a hash function for different types?

2019-08-02 Thread Jesse Wang
On Saturday, August 3, 2019 at 1:36:01 PM UTC+8, Jon Zeppieri wrote: > > On Sat, Aug 3, 2019 at 12:52 AM Jesse Wang > wrote: > > > > 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-

Re: [racket-users] How to implement a hash function for different types?

2019-08-02 Thread Jon Zeppieri
On Sat, Aug 3, 2019 at 1:35 AM Jon Zeppieri wrote: > > On Sat, Aug 3, 2019 at 12:52 AM Jesse Wang wrote: > > > > 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? > > > > T