I wrote a few examples up for explaining this: 
http://blog.jayfields.com/2010/12/clojure-get-get-in-contains-and-some.html

they might be helpful if you want additional info above and beyond the docs.

Cheers, Jay

On Aug 24, 2011, at 5:15 PM, Mark Rathwell wrote:

> See the doc below.  What (contains? [1 2] 1) is testing is whether [1
> 2] has a value at index 1 (the key value for numerically indexed
> collections).  It does, so it returns true.  What you are probably
> looking for is the Java method .contains of the vector:
> 
> (.contains ["a" "b"] "a")
> ;=> true
> 
> (.contains [1 2 5] 5)
> ;=> true
> 
> user> (doc contains?)
> -------------------------
> clojure.core/contains?
> ([coll key])
>  Returns true if key is present in the given collection, otherwise
>  returns false.  Note that for numerically indexed collections like
>  vectors and Java arrays, this tests if the numeric key is within the
>  range of indexes. 'contains?' operates constant or logarithmic time;
>  it will not perform a linear search for a value.  See also 'some'.
> 
> 
> 
> 
> On Wed, Aug 24, 2011 at 4:57 PM, Andrew Xue <and...@lumoslabs.com> wrote:
>> the below seems odd
>> 
>> user=> (contains? [1 2] 1)
>> true
>> user=> (contains? ["a" "b"] "a")
>> false
>> 
>> am i missing something?
>> 
>> --
>> 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 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 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

Reply via email to