(use 'clojure.contrib.math) ; for abs (apply min-key #(abs (- 136 %)) [1 3 137 -137 135 0 50 75])
A recent thread in this group noted that min-key applies the function multiple times and there's a better replacement. Also, if you're looking up many such numbers you might want to sort and do binary search. -- Eivind Magnus Hvidevold Cell: +47 926 78 423 On Sat, Sep 25, 2010 at 3:41 PM, Glen Rubin <rubing...@gmail.com> wrote: > I have a list of numbers and I want to find the one that is closest to > 136. Is there an operator for performing this kind of operation or do > I need to to do it algorithmically? > > thanks! > > -- > 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<clojure%2bunsubscr...@googlegroups.com> > 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 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