Is it ok if the index starts at 0? (use '[clojure.contrib.seq :only (indexed)])
(defn get-min-and-index [coll] (apply min-key #(second (second %)) (indexed coll))) user=> (get-min-and-index [[22 5] [56 8] [99 3] [43 76]]) [2 [99 3]] On Oct 26, 7:54 pm, Glen Rubin <rubing...@gmail.com> wrote: > I have a sequence like this: > > [ [a b] [a b] [a b] [a b] ] > > where a and b are numbers. I would like to return the vector and its > index for which b is the least in this collection. > > For example, if my data is as follows > > [ [22 5] [56 8] [99 3] [43 76] ] > > I would like to return 3rd vector in the collection where b is lowest > [99 3], but I also would like to know that it is the 3rd vector, so > maybe something like: > > [99 3 3] > > any suggestions??? > > thx a mil!! -- 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