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 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 it

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 paramet

Re: Back on max again...

2008-11-04 Thread Graham Fawcett
On Tue, Nov 4, 2008 at 10:00 AM, Christian Vest Hansen <[EMAIL PROTECTED]> wrote: > > 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 Com

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

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: > >

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: >

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 >

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: >> >>

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 poi

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 s

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 tha

Re: Back on max again...

2008-11-03 Thread Mark H.
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 im

Re: Back on max again...

2008-11-03 Thread Cosmin Stejerean
On Nov 3, 2008, at 8:35 PM, Mark H. wrote: > > 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

Re: Back on max again...

2008-11-03 Thread .Bill Smith
> 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. Agreed. For example, the semantics of "max string" are locale- dependent. Bill --~--~-~--~~~---~--

Re: Back on max again...

2008-11-03 Thread Matt Revelle
On Nov 3, 2008, at 9:35 PM, Mark H. wrote: > > 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

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

Back on max again...

2008-11-03 Thread Paul Stadig
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 max. Calling max gives an exception about not being able to