On Fri, Jan 23, 2009 at 2:39 PM, Justin Johnson <ajustinjohn...@gmail.com> wrote: > On Fri, Jan 23, 2009 at 2:32 PM, Mark Volkmann <r.mark.volkm...@gmail.com> > wrote: >> >> This must be something I learned months ago and then forgot ... >> embarassing! >> What's the easiest way to determine if a sequence contains a given value? >> I thought there would be something like this: (include? [2 4 7] 4) -> true >> That doesn't exist. >> I know I can do this: (some #{4} [2 4 7]) >> Having to create a set seems overkill. > > user=> (contains? [1 2 3] 1) > true
That doesn't do what you think it does. For example, (contains? [2 4 7] 4) -> false The doc string includes this: "Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes." So it doesn't compare the values. I'd like to use it with strings like this to determine if a letter is a vowel: (contains? "aeiou" letter) but that doesn't work either. -- R. Mark Volkmann Object Computing, Inc. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---