On Mon, Mar 2, 2009 at 6:54 AM, David Sletten <da...@bosatsu.net> wrote: > > Does Clojure have an analog of Lisp's MEMBER function? > (member 'a '(c a f e b a b e)) => (A F E B A B E) > > (I'm more interested in it's use as a predicate rather than the fact > that it returns a sublist when true.) > > "find" and "contains?" are listed under the Maps section of the data > structures page (http://clojure.org/data_structures#toc17) so no good > with lists. I can't think of any other synonyms. > > The documentation for "some" suggests this: > (some (fn [elt] (= elt 'a)) '(a b c)) => true > That's pretty verbose, and even the shortcut is kinda long: > (some #(= % 'a) '(a b c)) => true
It's verbose in order to discourage its use since its a linear search. See the discussion about the contains? function at http://www.ociweb.com/mark/clojure/article.html#Lists and http://www.ociweb.com/mark/clojure/article.html#Sets. -- 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 -~----------~----~----~----~------~----~------~--~---