[Haskell-cafe] Very imperfect hash function
Richard O'Keefe
ok at cs.otago.ac.nz
Mon Feb 1 21:05:34 EST 2010
On Feb 1, 2010, at 9:04 AM, Hans Aberg wrote:
> A simple hash-function for strings is to simply exclusive-or the
> bytes and then reduce modulo a prime number,
Simply exclusive-oring the bytes will give you at most 256 distinct
results. (For an ASCII source, 128 distinct results.) After that,
there hardly seems to be any point in reduction modulo a prime.
This approach can't tell a CAT from an ACT or a DOG from a GOD, which
is another strike against it. (It also can't tell a TITTLE from a TILE,
or a BOTTLE from a BOLE, for obvious reasons.)
More information about the Haskell-Cafe
mailing list