On Mon, 27 Mar 2006 07:50:01 -0800, Arne Ludwig wrote:
> Just for completeness: The functions in Steve's original post named
> maximum calculate the minimum.
Er, yes. I benchmarked them but clearly I should have function-tested
them as well.
Here is, I hope, my last word on maximum(). It figu
"Arne Ludwig" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Just for completeness: The functions in Steve's original post named
> maximum calculate the minimum.
>
> Also, timing-wise, on my machine with a random list of 20 integers
> Steve's iteration version and Mitja's version
Just for completeness: The functions in Steve's original post named
maximum calculate the minimum.
Also, timing-wise, on my machine with a random list of 20 integers
Steve's iteration version and Mitja's version are about equal, the
system built-in is equal or slightly slower, and Paul's versi
On Mon, 27 Mar 2006 00:11:04 +, Paul McGuire wrote:
> The doc string is not correct.
The fault is mine, I'm afraid. I had thought I was copying that from an
intact original version, but I must have edited it. I don't remember
doing it, but I must have.
To check, I went to Sourceforge and do
Steve R. Hastings wrote:
> On Sun, 26 Mar 2006 10:34:16 -0700, Steven Bethard wrote:
>> What's the original?
>
> def minimum(cmp, lst):
> """minimum(cmp, lst)
>
> Returns the minimal element in non-empty list LST with elements
> compared via CMP() which should return values with the same se
"Steve R. Hastings" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Sun, 26 Mar 2006 10:34:16 -0700, Steven Bethard wrote:
> > What's the original?
>
>
>
> def minimum(cmp, lst):
> """minimum(cmp, lst)
>
> Returns the minimal element in non-empty list LST with elements
> comp
Actually, now that I think about it, the version using iter() has one
advantage over your version: it will work correctly if passed either a
list or an iterator. So, for versions of Python that have iterators, I'd
use the iter() version, but for older versions of Python, I'd use your
version.
P.S
On Sun, 26 Mar 2006 10:34:16 -0700, Steven Bethard wrote:
> What's the original?
def minimum(cmp, lst):
"""minimum(cmp, lst)
Returns the minimal element in non-empty list LST with elements
compared via CMP() which should return values with the same semantics
as Python's cmp(). If there
On Sun, 26 Mar 2006 20:34:28 +0200, Mitja Trampus wrote:
> I would have done it in the same way, but probably without the iterators.
> I.e., like this:
>
> def maximum(lst):
> try: m = lst[0]
> except (TypeError, IndexError): raise Exception "Non-sequence or empty
> sequence given to
"Steve R. Hastings" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I was looking at a Python function to find the maximum from a list.
> The original was more complicated; I simplified it. The built-in max()
> function can replace the simplified example, but not the original.
>
>
If
Steve R. Hastings wrote:
> I was looking at a Python function to find the maximum from a list.
> The original was more complicated; I simplified it. The built-in max()
> function can replace the simplified example, but not the original.
But you forgot to shuw us the original...
[snip several im
Steve R. Hastings wrote:
> I was looking at a Python function to find the maximum from a list.
> The original was more complicated; I simplified it. The built-in max()
> function can replace the simplified example, but not the original.
What's the original? Are you sure max can't solve it with
I was looking at a Python function to find the maximum from a list.
The original was more complicated; I simplified it. The built-in max()
function can replace the simplified example, but not the original.
def maximum(lst):
maxval = lst[0]
for i in xrange(1, len(lst)):
v = lst[i]
i
13 matches
Mail list logo