Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Should max and min have 0-arg implementations?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Aaron Cohen  
View profile  
 More options Jul 9 2010, 1:18 pm
From: Aaron Cohen <aa...@assonance.org>
Date: Fri, 9 Jul 2010 13:18:34 -0400
Local: Fri, Jul 9 2010 1:18 pm
Subject: Should max and min have 0-arg implementations?

I noticed that http://clojure-examples.appspot.com/clojure.core/max has both
(apply max [1 2 3 4]) -> 4 and (max []) -> [] (which I think is a poor
example).

However, when attempting to add another example for (apply max []) which I
expected to return nil, that instead it throws an exception.

I have to admit, I've never come across this in practice, but it seems like
adding the overload would be nice for generality.

-- Aaron


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stuart Halloway  
View profile  
 More options Jul 9 2010, 1:57 pm
From: Stuart Halloway <stuart.hallo...@gmail.com>
Date: Fri, 9 Jul 2010 13:57:05 -0400
Local: Fri, Jul 9 2010 1:57 pm
Subject: Re: Should max and min have 0-arg implementations?

Once you walk down the path of "What should (max) return?" I think you won't want a default behavior.

Stu

P.S. Agreed that (max []) is a bad example.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Bug in 1-arg max/min implementation? (Was: Should max and min have 0-arg implementations?)" by Mike Meyer
Mike Meyer  
View profile  
 More options Jul 9 2010, 3:14 pm
From: Mike Meyer <mwm-keyword-googlegroups.620...@mired.org>
Date: Fri, 9 Jul 2010 15:14:56 -0400
Local: Fri, Jul 9 2010 3:14 pm
Subject: Bug in 1-arg max/min implementation? (Was: Should max and min have 0-arg implementations?)
On Fri, 9 Jul 2010 13:57:05 -0400

Stuart Halloway <stuart.hallo...@gmail.com> wrote:
> Once you walk down the path of "What should (max) return?" I think you won't want a default behavior.

> Stu

> P.S. Agreed that (max []) is a bad example.

Given that max only works on numbers, then why doesn't (max []) throw
the same exception as (max [] [])? Or, for that matter, (max \a) throw
the same exception as (max \a \b \c)?

If max worked on any comparable (which is what I expected), then (max
A) always returning A makes sense, even if A isn't comparable. But
that behavior when max is defined as only working on numbers sure
seems like a bug.

      <mike
--
Mike Meyer <m...@mired.org>           http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Engelberg  
View profile  
 More options Jul 9 2010, 3:58 pm
From: Mark Engelberg <mark.engelb...@gmail.com>
Date: Fri, 9 Jul 2010 12:58:22 -0700
Local: Fri, Jul 9 2010 3:58 pm
Subject: Re: Bug in 1-arg max/min implementation? (Was: Should max and min have 0-arg implementations?)

> Given that max only works on numbers, then why doesn't (max []) throw
> the same exception as (max [] [])? Or, for that matter, (max \a) throw
> the same exception as (max \a \b \c)?

Clojure tends not to guarantee any particular behavior for invalid
inputs.  It might return an error, or it might give back a spurious
answer.

Most likely, the code for max just has a case that if it is only
passed a single input, then that is the answer.  No error checking is
performed.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »