Re: Long as keys in hash-map

2010-05-20 Thread Mibu
Jason, this was very helpful. sorted-map's correct behavior compared to the naive behavior of hash-map is what confused me. Thanks for clearing this up. On May 21, 6:31 am, Jason Wolfe wrote: > The crux of the issue: > > user> (= (long 1) (int 1)) > true > user> (.equals (long 1) (int 1)) > fals

Re: Long as keys in hash-map

2010-05-20 Thread Adrian Cuthbertson
On Fri, May 21, 2010 at 4:57 AM, Mibu wrote: > I tried to use Long keys from the java.io.File/length method in a hash- > map and failed to retrieve values using them. sorted-map is fine. The > doc says hash-maps require keys that support .equals and .hashCode. > Doesn't Long support those or am I

Re: Long as keys in hash-map

2010-05-20 Thread Jason Wolfe
The crux of the issue: user> (= (long 1) (int 1)) true user> (.equals (long 1) (int 1)) false user> (.equals (int 1) 1) true user> (.equals (long 1) 1) false So, as you can see, small integer literals are Integers by default in Clojure. And, while Integers and Longs with the same value are Cloju

Re: Long as keys in hash-map

2010-05-20 Thread MarkSwanson
On May 20, 10:57 pm, Mibu wrote: > I tried to use Long keys from the java.io.File/length method in a hash- > map and failed to retrieve values using them. sorted-map is fine. The > doc says hash-maps require keys that support .equals and .hashCode. > Doesn't Long support those or am I missing so