On Sat, 3 Jan 2009 01:32:08 -0800 (PST)
Jason <jawo...@berkeley.edu> wrote:

> 
> Is this desired behavior for contains?
> 
> 1:1 user=> (= [1 2] '(1 2))
> true
> 1:2 user=> (contains? (hash-set [1 2]) '(1 2))
> false
> 1:3 user=> (contains? (sorted-set [1 2]) '(1 2))
> java.lang.ClassCastException: clojure.lang.PersistentList (repl-1:2)
> 1:4 user=> (contains? (hash-map [1 2] nil) '(1 2))
> false
> 1:5 user=> (contains? (array-map [1 2] nil) '(1 2))
> true
> 
> As far as I can figure all five of these should return true (the
> exception is particularly weird).  Am I missing something here?

Im just starting with clojure but to me it looks right.

In the first case the compare is true because its comparing them by
value, whereas in all the other cases it fails because you are asking
if a structure with a vector in it contains a list, which isnt true
because its not comparing them by value but by identity.

thats how i would understand it.

So if you change 1 to :

(== [1 2] '(1 2))

then you get false for that as well.


--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to