I like this proposal. I'd make contains? an alias for contains-key? with a deprecation warning, and just forget about seq-contains? in favor of contains-val?
On Thursday, April 29, 2010, ataggart <alex.tagg...@gmail.com> wrote: > I know it won't matter, but for posterity if nothing else... > > Functions named contains-key? and contains-val? would make a lot more > sense to me than the current contains? and new seq-contains?. Anyone > looking at contains-val? should expect it to be O(n). The only > effective difference would be that the test value for contains-val? is > consistently a single value rather than a [key value] tuple for maps. > > Lists: > (contains-key? '(:foo :bar) 0) > Exception > (contains-val? '(:foo :bar) :foo) > true > > Vectors: > (contains-key? [:foo :bar] 0) > true > (get [:foo :bar] 0) > :foo > (contains-key? [:foo :bar] 2) > false > (contains-val? [:foo :bar] :foo) > true > (contains-val? [:foo :bar] :baz) > false > > Maps: > (contains-key? {:foo :bar} :foo) > true > (get {:foo :bar} :foo) > :bar > (contains-key? {:foo :bar} :baz) > false > (contains-val? {:foo :bar} :bar) > true > (contains-val? {:foo :bar} :baz) > false > > Sets: > (contains-key? #{:foo :bar} :foo) > true > (get #{:foo :bar} :foo) > :foo > (contains-key? #{:foo :bar} :baz) > false > (contains-val? #{:foo :bar} :foo) > true > (contains-val? #{:foo :bar} :baz) > false > > -- > 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 -- Mark J. Reed <markjr...@gmail.com> -- 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