From: Raymond T. <to...@rt...> - 2002-11-08 17:13:10
|
>>>>> "William" == William Harold Newman <wil...@ai...> writes: William> this idea in terms of existing SBCL code would be William> (defun get-instance-hash-code () William> (mix 1234567 William> (mod (incf hash-code delta) William> (1+ most-positive-fixnum)))) William> And if we had some stronger hash function than MIX (imagine using MD5 William> or something of the sort, though presumably neither so insanely William> thorough nor so computationally expensive), that'd work better. But William> for now I thought the bang-for-the-buck of just linear congruential William> distribution was sufficient. Why is this linear congruential? I always thought it would be something like (mod (* hash-code a) (1+ most-positive-fixnum)) for some suitably selected a, except this conses quite a bit. A reasonable alternative might be the Weyl generator used in the :new-random generator (deprecated, now): (mod (- x a) 1.0) where x and a are floating-point numbers. I think this can all be done without consing, and the conversions between fixnum and floats is fast too. Ray |