The naming of contains? is one of Clojure's small warts. Almost everyone seems to stumble over it when they're starting out. I know I did. Naming it contains-key? would have prevented a great deal of confusion, but I guess that ship has sailed... *shrug*
// ben On Tue, Sep 4, 2012 at 1:35 PM, Jim - FooBar(); <jimpil1...@gmail.com> wrote: > personally I've gotten used to it but it seems that every couple of weeks > someone else will be confused and try to use contains? as it would be used > in Java...the docs are clear but unfortunately not everyone consults the > docs beforehand! at least not for such a semantically clear name as > "contains?"... > > Jim > > > On 04/09/12 10:01, Marcus Lindner wrote: > > I think this is not a bad idea. ;) > At all, a method/function name should describe what it does. And if > 'contains?' only looks for keys, then 'contains-key?' would be a better > descriptor for it. > > Am 03.09.2012 13:29, schrieb Jim - FooBar();: > > this is probably the single most confusing name in clojure! :-) > why can't we make it "contains-key?" ? > > Jim > > On 03/09/12 12:14, Goldritter wrote: > > Ah ok. So I need to transform a vector and/or a list into a set first. > > Thanks. > > Am Montag, 3. September 2012 13:05:52 UTC+2 schrieb Ambrose > Bonnaire-Sergeant: >> >> 'contains?' tests if a key is in a collection. >> >> Vector is an associative data structure, with keys being indexes. >> A vector of length 3 has the key 2, but not key 3. >> >> Thanks, >> Ambrose >> >> On Mon, Sep 3, 2012 at 7:03 PM, Goldritter >> <marcus.goldr...@googlemail.com> wrote: >>> >>> I use Clojure 1.4.0 and wanted to use 'contains?' on a vector and get >>> following results: >>> >>> => (contains? [1 2 3] 3) >>> false >>> => (contains? [1 2 3] 2) >>> true >>> >>> As it seems 'contains?' does not check for the last entry in the vector. >>> >>> And an other question. >>> Why does contains? returns everytime 'false' when used on a list? >>> => (contains? (list 1 2 3) 1) >>> false >>> => (contains? (list 1 2 3) 2) >>> false >>> => (contains? (list 1 2 3) 3) >>> false >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Clojure" group. >>> To post to this group, send email to clo...@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+u...@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 > > > -- > 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