The strings I'm working with are ISO formatted dates, and one of the
reasons many people like to use ISO formatted dates is that they sort
easily. However, the specifics of the situation are really irrelevant.

I just thought it might be seen as incongruent that Clojure has an
elegant collection system based on the Collections interfaces, and
have max and min functions that only operate on numbers. It would seem
we should embrace the Comparable and Comparator interfaces as well.


Paul

On Tue, Nov 4, 2008 at 12:23 AM, Mark H. <[EMAIL PROTECTED]> wrote:
>
> On Nov 3, 6:48 pm, Cosmin Stejerean <[EMAIL PROTECTED]> wrote:
>> I think clearly spelling out how objects of a type should be sorted is
>> the point of the Comparable interface.
>
> Ah, yes, this is true, I hadn't realized that String and Date both
> implement Comparable.  Comparable is supposed to impose a total
> ordering on a set, so in a finite set of objects of the same type, the
> max is always well defined.
>
> If I wanted the max of a set of strings representing dates, however,
> I'd still comment the code to indicate what "max" means.  I'd also
> consider replacing "(max dates)" in my code with a helper function
> whose name makes the comment unnecessary:  "(defn most-recent [dates]
> (max dates))" or something like that.
>
> mfh
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to