On Oct 23, 2013, at 17:03 , Mark Engelberg <mark.engelb...@gmail.com> wrote:

> It is true that it must be commutative, but not true that it must be 
> non-associative.  Here is a sample implementation of a hash function for sets 
> that is commutative and associative but doesn't collide for these sorts of 
> common rearrangements.  The idea of this proof of concept is that the hash 
> value of a set is the sum of (expt 3 (abs (hash item))) for each item in the 
> set.

Associativity is only meaningful for binary operators-- I was assuming a binary 
hash-combining function that would be applied via reduce or such. The function 
you've described can't be implemented as a binary operator without changing its 
behavior, so it can't be described as associative. But you're right that Set's 
hash function doesn't need to be associative, since it doesn't actually need to 
be a binary operator.

BTW, while looking into this I discovered that Clojure already defines a 
function clojure.lang.Util/hashCombine that uses Boost's hash-combining 
algorithm, but it doesn't seem to be used for anything except Symbols at the 
moment.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to