Unordered map
Johannes Waldmann
waldmann at imn.htwk-leipzig.de
Fri Aug 1 12:11:53 EDT 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
> [...] Two different languages, two different
> approaches to implementing collections---one more imperative, the other
> more functional.
It's "easier" to implement Hash than Ord,
because for Ord, you need transitivity.
while a hash function just needs to be a function.
(Difficult in Java, impossible to get wrong in Haskell.)
If you take a bad hash function,
you're "only" hurting performance, not correctness.
In fact I sometimes make a wrapper type sth. like
Wrap { hash = hash x, contents = x } deriving ( Eq, Ord )
(hoping for the left-to-right comparison)
and then use Data.Map.
Best regards, J.W.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iEYEARECAAYFAkiTNckACgkQDqiTJ5Q4dm+FXgCeNLHcnFHCB+Bq9xJyv+qY1UE+
P+4Anja7agfdrTpDHcN9GAT3hkzav7jc
=Jv1z
-----END PGP SIGNATURE-----
More information about the Libraries
mailing list