On Wednesday, 11 February 2009 00:18:53 UTC+8, Jeff Rose wrote: > Hi, > Is there a built-in function that will return the first item in a > collection that matches a predicate? (Something equivalent to Ruby's > Enumerable#find...) Seems pretty basic, but I can't find it in the docs. > > Thanks, > Jeff > See the find-first function in my cljutils library: https://github.com/mikera/clojure-utils/blob/master/src/main/clojure/mikera/cljutils/find.clj
Note the initial check to see if the collection is Indexed: if it is then it is better to search by index than to create a seq (which causes a lot of unnecessary allocations) -- -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
