On Fri, Feb 27, 2015 at 12:01:16PM +0100, Enrique Sánchez wrote:
> > initSeed() should be improved, by doing more than simply adding up the
> > 32-bit or 64-bit "digits", at least in case of symbols. Any proposals?
> I discovered these collisions while comparing the picolisp hash function
> with the djb2 string hash function, that didn't have that problem.
> May be a solution could be to use the djb2 hash function:
> (de djb2 (S)
> (let A 5381
> (for C (chop S)
> (setq A (& 65535 (+ (* 33 A) (char C)))) ) ) )
OK, but I had rather an extension of the built-in C/asm function in
Something which operates on 32- or 64-bit binary numbers (a shortnum, or
the digits of a bignum), and which gives equally good results for:
- Big numbers, with almost all bits in the word being significant
- Small numbers, where only the lowest few bits are used
- Numbers representing packed ASCII data (as in your case above)