On Nov 3, 5:39 pm, "Paul Stadig" <[EMAIL PROTECTED]> wrote:
> Could/Should the max function be modified to work against the
> Comparable interface instead of expecting its arguments to be numbers?
>
> I'm working with a sequence of strings that are dates in the
> "yyyy-mm-dd" format, and I want to find the max. Calling max gives an
> exception about not being able to cast to a java.lang.Number.

I vote "no, max shouldn't be modified" because

1. The notation is ambiguous in the context of dates.  What's the
"max" date?  The most recent one, or the oldest one?
2. Even if everyone agrees on what the "max date" of a sequence of
dates means, you're asking what "max" means for a sequence of
strings.  You're thinking of some kind of dictionary order, but some
people might want to use string length.  Since your version of max
would accept arbitrary strings, it would break for dates represented
using a different string format.

The semantics of "max string" are unclear enough that it would be
better to write out the operation explicitly so that all readers of
the code know what you mean.

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