Re: Wrong documentation of contains?

2013-08-07 Thread Armando Blancas
The keys docstring says it returns a sequence, and that's all you get: it'll do first and next, nothing special about it. The contains? docstring says it won't do a linear search, so that rules out the result of keys. (KeySeq just wraps a seq of entries to return the key field.) What's confusin

Re: Wrong documentation of contains?

2013-08-07 Thread Jonathan Fischer Friberg
No, it should be more explicit. "If called with a map..." "If called with a vector..." Jonathan On Wed, Aug 7, 2013 at 8:32 PM, Michael Gardner wrote: > Wouldn't changing "collection" to "associative collection" be enough? > Though maybe a note about its behavior on vectors would also be good.

Re: Wrong documentation of contains?

2013-08-07 Thread Michael Gardner
Wouldn't changing "collection" to "associative collection" be enough? Though maybe a note about its behavior on vectors would also be good. On Aug 7, 2013, at 11:15 , Mark Engelberg wrote: > Yes, the discussion about contains? has come up before, but there's a new > aspect to this particular i

Re: Wrong documentation of contains?

2013-08-07 Thread Mark Engelberg
Yes, the discussion about contains? has come up before, but there's a new aspect to this particular instance of the discussion that most of the posts seem to be ignoring. The original poster specifically pointed out that his sequence was constructed by calling the `keys` function on a map: (keys {

Re: Wrong documentation of contains?

2013-08-07 Thread Jim - FooBar();
aa the old 'why contains? doesn't work' discussion...even though it's been a while since it last came up on this list, it must be the single most popular questions :) Jim On 07/08/13 12:24, Goldritter wrote: In an program I used the result of keys as an argument for a function which ve

Re: Wrong documentation of contains?

2013-08-07 Thread Jay Fields
I ran into a similar (in my opinion) issue the other day. I was working a vector and updating a value at a specific index. Ordering and performance were important, so it seemed like a good default choice. (-> [1 2 3] (update-in [1] inc)) Then the code changed a bit, I needed to filter some eleme

Re: Wrong documentation of contains?

2013-08-07 Thread Lee Spector
On Aug 7, 2013, at 8:22 AM, Jay Fields wrote: > contains? is possibly poorly named, contains-key? would probably have avoided > this entire issue. I'd put it more strongly -- contains? is definitely poorly named, inviting the assumption that it can be used where you really want "some" with a s

Re: Wrong documentation of contains?

2013-08-07 Thread Tassilo Horn
Jay Fields writes: > For a list, it seems like converting the list to a vectoc (via vec) > would be a reasonable solution, though I'm sure there's some side > effect that I haven't considered. Perf would be impacted, but this > doesn't seem like the kind of thing you'd want to do anyway, so havin

Re: Wrong documentation of contains?

2013-08-07 Thread Jay Fields
contains? is possibly poorly named, contains-key? would probably have avoided this entire issue. That said, I'd like to see contains? return false for things where it doesn't make sense, longs, keywords, etc. For a list, it seems like converting the list to a vectoc (via vec) would be a reasonable

Re: Wrong documentation of contains?

2013-08-07 Thread Jonathan Fischer Friberg
That's only obvious if you already know how it works. Jonathan On Wed, Aug 7, 2013 at 2:13 PM, Karsten Schmidt wrote: > The fact, that the docs refer to checking if a "key" is present in the > collection, should make it obvious which types are supported, no? Only > vectors, maps and sets have ke

Re: Wrong documentation of contains?

2013-08-07 Thread Karsten Schmidt
The fact, that the docs refer to checking if a "key" is present in the collection, should make it obvious which types are supported, no? Only vectors, maps and sets have keys. Lists and seqs do not. Of course it never hurts to be more explicit about it... On 7 Aug 2013 12:49, "Marcus Lindner" wrot

Re: Wrong documentation of contains?

2013-08-07 Thread Tassilo Horn
Marcus Lindner writes: > But the problem is, that this is not mentioned in the documentation of > contains? I found so far :(. Well, it kind of is: Only associative data structures (maps, sets, records, vectors) have keys, lists and seqs (such as APersistentMap$KeySeq) don't. I guess the confus

Re: Wrong documentation of contains?

2013-08-07 Thread Marcus Lindner
Thanks. But the problem is, that this is not mentioned in the documentation of contains? I found so far :(. I had such a problem a long time ago and remember now which type of "collection" can be used with contains?. But after a time I will forget this again and will refer to the documentation. (A

Re: Wrong documentation of contains?

2013-08-07 Thread Baishampayan Ghose
Hi, `contains?` only works with associative data-structures like maps & vectors. If you want to find out if a sequence contains a specific object then you need to use `some` paired with a set as a predicate. For example: (some #{3} '(1 2 3 4)) Hope this helps. ~BG On Wed, Aug 7, 2013 at 4:54

Wrong documentation of contains?

2013-08-07 Thread Goldritter
In an program I used the result of keys as an argument for a function which verifies whether an object is in a passed collection or not. The result I got was following Exception: IllegalArgumentException contains? not supported on type: clojure.lang.APersistentMap$KeySeq clojure.lang.RT.contains