Why must the second argument of `hash` come from another hash function?

I think I would probably use get_selector.(hash.(1:100), 0.1). The reason for documenting that the 2nd argument (when not 0) should be the result of a hash, is that it means that you don’t need to mix that argument up at all. You can just assume it’s a roughly uniformly distributed UInt. For example, the way an Int gets hashed is

hash(x::Int64,  h::UInt) = hash_uint64(bitcast(UInt64, x)) - 3h

so if you call this with consecutive numbers, you will obviously get highly correlated results.

2 Likes