[erlang-questions] Warning: erlang:phash2 output
Bjorn Gustavsson
bgustavsson@REDACTED
Thu May 7 09:26:32 CEST 2009
2009/5/7 Paulo Sérgio Almeida <psa@REDACTED>:
> Martin Bjorklund wrote:
>
>> Actually, phash2 uses a great hash function (by Robert Jenkins), if
>> you know how to invoke it -- you need to call it with a binary to get
>> this algorithm.
Actually, it produces good hash values for any term *except* atoms.
If you have term that contains atoms (e.g. atoms in a list or tuple), you
will probably get a decent hash value anyway because the hash for
the atoms is mixed into the hash value calculated by the list or the
tuple.
Try:
erlang:phash2([a]).
erlang:phash2([b]).
erlang:phash2([c]).
/Bjorn
--
Björn Gustavsson, Erlang/OTP, Ericsson AB
More information about the erlang-questions
mailing list