On Dec 2, 1:08 pm, Stefan Kamphausen <[email protected]> wrote:
> Hi,
>
> On Dec 2, 9:06 pm, ataggart <[email protected]> wrote:
>
> > > I'd like to understand the (probably well-grounded) reason for that.
> > > As far as I can see PersistentList extends Counted, so the check for
> > > the index-range should at least be possible.  However, I think people
> > > would expect an equality check in the background, which OTOH would be O
> > > (N), probably.
>
> > > Kind regards,
> > > Stefan
>
> > That's because contains? checks for keys not values.  Since a list
> > isn't associative (unlike vectors and maps), it doesn't have keys,
>
> but at least the position within the list could be interpreted as the
> key, although I personally would prefer if the
> items themselves would count as keys.
>
> > thus contains? doesn't apply.
>
> But the implementation takes special care even of strings and arrays.
> From the website I got the impression that lists would be a collection-
> type ("Lists are collections."), and the arglist of contains? says it
> expects a coll.
>
> >  I too was first thrown off by assuming
> > contains? worked on the values of a collection;
>
> So, that makes two already ;-)
>
> Please don't get me wrong.  No criticism here about doc-code-
> differences or about the decision to not support lists in contains?.
> I'm just asking for the reason.
>
> Kind regards,
> Stefan

My guess is that String and array, while not implementing the
IAssociative interface, all have the O(1) lookup performance
guarantees of associative data structures, thus could be added.  I
think the docs are terse precisely because it allows Rich, et al. to
add in support for stuff like Strings at a later date.  Either way, it
might be worthwhile to amend the docs to note that coll must at least
support O(1) lookup.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to