What about something like: (defn gt [str1 str2] (first (sort [str1 str2])))
(gt "Zoe" "Bob") ; -> "Bob" On Fri, Feb 27, 2009 at 12:03 PM, Phil Hagelberg <p...@hagelb.org> wrote: > > Christian Vest Hansen <karmazi...@gmail.com> writes: > > >> Are you referring to using <, >, =, with objects that implement > >> java.lang.Comparable? > >> > >> i.e. given x.compareTo(y) == -1 > >> (< x y) > >> => true > >> > >> I would find that useful. > > > > I think having <, >, <=, >= be based on Comparable has been discussed > before. > > > > And the conclusion was that it was a bad idea, because in Java: > > > > user=> (.compareTo (Integer. "10") (Long. "10")) > > java.lang.ClassCastException: java.lang.Long cannot be cast to > > java.lang.Integer (NO_SOURCE_FILE:0) > > > > And: > > > > user=> (.equals (Integer. "10") (Long. "10")) > > false > > Curses, Java! Foiled again. > > > Given these consequences, I think the current behavior is the best > compromise. > > Agreed. Am curious as to what the idiomatic way to check to see if one > string is alphabetically greater than another is though. > > -Phil > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---