Re: Back on max again...

2008-11-04 Thread Paul Stadig
On Tue, Nov 4, 2008 at 7:45 AM, Rich Hickey [EMAIL PROTECTED] wrote: Hmm... Do you want: (max 1 2.1 4/5) to work? If so, you can't base it on Comparable, which generally only supports homogenous types. max, like , is a numeric operation as it stands, for the above and speed reasons.

Re: Back on max again...

2008-11-04 Thread Rich Hickey
On Nov 4, 9:00 am, Christian Vest Hansen [EMAIL PROTECTED] wrote: On Tue, Nov 4, 2008 at 1:45 PM, Rich Hickey [EMAIL PROTECTED] wrote: On Nov 4, 2:56 am, Christian Vest Hansen [EMAIL PROTECTED] wrote: On Tue, Nov 4, 2008 at 6:23 AM, Mark H. [EMAIL PROTECTED] wrote: On Nov 3, 6:48

Re: Back on max again...

2008-11-04 Thread Cosmin Stejerean
On Tue, Nov 4, 2008 at 6:45 AM, Rich Hickey [EMAIL PROTECTED] wrote: On Nov 4, 2:56 am, Christian Vest Hansen [EMAIL PROTECTED] wrote: On Tue, Nov 4, 2008 at 6:23 AM, Mark H. [EMAIL PROTECTED] wrote: On Nov 3, 6:48 pm, Cosmin Stejerean [EMAIL PROTECTED] wrote: I think clearly

Re: Back on max again...

2008-11-04 Thread Christian Vest Hansen
On Tue, Nov 4, 2008 at 3:12 PM, Rich Hickey [EMAIL PROTECTED] wrote: On Nov 4, 9:00 am, Christian Vest Hansen [EMAIL PROTECTED] wrote: Generally by custom but not required by contract of the Comparable interface. And those are all Numbers, right? Comparable imposes natural ordering, and the

Re: Back on max again...

2008-11-04 Thread Paul Stadig
I have a kind of random question that may not make any sense, but I'm going to throw it out there. Is it possible to create generic macros? I mean macros are basically a way to extend the compiler, right? Wouldn't it be useful to be able to dispatch a macro based on the type hint of its

Re: Back on max again...

2008-11-04 Thread Paul Stadig
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

Re: Back on max again...

2008-11-04 Thread Konrad Hinsen
On Nov 4, 2008, at 18:18, Paul Stadig wrote: Is it possible to create generic macros? I mean macros are basically a way to extend the compiler, right? Wouldn't it be useful to be able to dispatch a macro based on the type hint of its parameters (or some other criteria)? A macro gets its

Re: Back on max again...

2008-11-04 Thread Paul Stadig
Metadata (including type hints) are attached to symbols by the reader, so I'm thinking something like: (def a 1) (def b 2) (defn greatest-by Return the 'largest' argument, using compare-fn as a comparison function. [compare-fn args] (reduce #(if (pos? (compare-fn %1 %2)) %1 %2) args))

Re: Back on max again...

2008-11-04 Thread Rich Hickey
On Nov 4, 2:56 am, Christian Vest Hansen [EMAIL PROTECTED] wrote: On Tue, Nov 4, 2008 at 6: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

Re: Back on max again...

2008-11-04 Thread Christian Vest Hansen
On Tue, Nov 4, 2008 at 1:45 PM, Rich Hickey [EMAIL PROTECTED] wrote: On Nov 4, 2:56 am, Christian Vest Hansen [EMAIL PROTECTED] wrote: On Tue, Nov 4, 2008 at 6:23 AM, Mark H. [EMAIL PROTECTED] wrote: On Nov 3, 6:48 pm, Cosmin Stejerean [EMAIL PROTECTED] wrote: I think clearly spelling

Re: Back on max again...

2008-11-03 Thread Mark H.
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 -mm-dd format, and I want to find the

Re: Back on max again...

2008-11-03 Thread Christian Vest Hansen
On Tue, Nov 4, 2008 at 6: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