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 confusing to me here is that coll? will return true on a sequence.

On Wednesday, August 7, 2013 9:15:54 AM UTC-7, puzzler wrote:
>
> 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 {:a "f" :b 23})
>
> He then went on to point out that it doesn't return just a regular, 
> ordinary lazy sequence, but some sort of special type called a "KeySeq".
>
> The documentation says that `contains?` looks for whether a given "key" is 
> present.  Probably when the documentation was written, there was some 
> assumption that by saying it looks for a "key", that makes it obvious it 
> only works on associative collections.
>
> But look here, we've got a sequence of keys.  We know it is comprised of 
> keys, and obviously Clojure knows it is a sequence just of keys (because of 
> the custom type).  Therefore, it was reasonable for the poster to think 
> that `contains?` would work on to determine whether a given key was in the 
> collection -- it is a collection with keys!
>
> So I think the new idea here, worthy of discussion, is this:
>
> How can we reword the doc for `contains?` so that it clearly does not 
> apply to a sequence of keys?
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to