I write again my post because the previous was bad written and I want to respect the Englis language the more as I can. With your question, I'm feeling you think each item has a different hash code. But it's wrong. You can meet collisions. An hash code is not an id, it's a way to find an element. So even if it's weird to have the same hash code for 0 and nil, this case is useful because it's shown you a case of collisions.
Le jeudi 20 décembre 2012 19:04:06 UTC+1, Stathis Sideris a écrit : > > Hello, > > I noticed the following: > > > (hash 0) > 0 > > (hash nil) > 0 > > Which is fair enough I suppose. It seems to have the following side-effect > though: > > > (hash [1 2 3 0]) > 955327 > > (hash [1 2 3 nil]) > 955327 > > Is that the intended behaviour? I suppose it's OK for two things to hash > to the same value, but IMHO, it would make the hash function more useful to > avoid this simple case. The implementation seems to check for nil > specifically and to return 0. > > Thanks, > > Stathis > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
