Wolfgang Maier於 2013年3月13日星期三UTC+8下午6時43分38秒寫道:
> Steven D'Aprano pearwood.info> writes:
>
>
>
> >
>
> > On Tue, 12 Mar 2013 17:03:08 +, Norah Jones wrote:
>
> >
>
> > > For example:
>
> > > a=[-15,-30,-10,1,3,5]
>
> > >
>
> > > I want to find a negative and a positive minimum.
>
On 13/03/2013 14:12, Steven D'Aprano wrote:
On Wed, 13 Mar 2013 11:23:22 +, Oscar Benjamin wrote:
On 13 March 2013 10:43, Wolfgang Maier
wrote:
thinking again about the question, then the min() solutions suggested
so far certainly do the job and they are easy to understand. However,
if y
Chris Angelico gmail.com> writes:
>
> > Sort cannot be O(log(n)) and it cannot be faster than a standard O(n)
> > minimum finding algorithm. No valid sorting algorithm can have even a
> > best case performance that is better than O(n). This is because it
> > takes O(n) just to verify that a list
On Wed, 13 Mar 2013 11:23:22 +, Oscar Benjamin wrote:
> On 13 March 2013 10:43, Wolfgang Maier
> wrote:
>>
>> thinking again about the question, then the min() solutions suggested
>> so far certainly do the job and they are easy to understand. However,
>> if you need to run the function repea
Wolfgang Maier wrote:
> Oscar Benjamin gmail.com> writes:
>
>>
>> Sort cannot be O(log(n)) and it cannot be faster than a standard O(n)
>> minimum finding algorithm. No valid sorting algorithm can have even a
>> best case performance that is better than O(n). This is because it
>> takes O(n) ju
On Wed, Mar 13, 2013 at 10:34 PM, Wolfgang Maier
wrote:
> Oscar Benjamin gmail.com> writes:
>
>>
>> Sort cannot be O(log(n)) and it cannot be faster than a standard O(n)
>> minimum finding algorithm. No valid sorting algorithm can have even a
>> best case performance that is better than O(n). Thi
On Wed, Mar 13, 2013 at 10:23 PM, Oscar Benjamin
wrote:
> On 13 March 2013 10:43, Wolfgang Maier
> wrote:
>>
>> thinking again about the question, then the min() solutions suggested so far
>> certainly do the job and they are easy to understand.
>> However, if you need to run the function repeate
Oscar Benjamin gmail.com> writes:
>
> Sort cannot be O(log(n)) and it cannot be faster than a standard O(n)
> minimum finding algorithm. No valid sorting algorithm can have even a
> best case performance that is better than O(n). This is because it
> takes O(n) just to verify that a list is sort
On 13 March 2013 10:43, Wolfgang Maier
wrote:
>
> thinking again about the question, then the min() solutions suggested so far
> certainly do the job and they are easy to understand.
> However, if you need to run the function repeatedly on larger lists, using
> min()
> is suboptimal because its p
Steven D'Aprano pearwood.info> writes:
>
> On Tue, 12 Mar 2013 17:03:08 +, Norah Jones wrote:
>
> > For example:
> > a=[-15,-30,-10,1,3,5]
> >
> > I want to find a negative and a positive minimum.
> >
> > example: negative
> > print(min(a)) = -30
> >
> > positive
> > print(min(a)) = 1
>
On Tue, 12 Mar 2013 17:03:08 +, Norah Jones wrote:
> For example:
> a=[-15,-30,-10,1,3,5]
>
> I want to find a negative and a positive minimum.
>
> example: negative
> print(min(a)) = -30
>
> positive
> print(min(a)) = 1
Thank you for providing examples, but they don't really cover all th
Wolfgang Maier biologie.uni-freiburg.de> writes:
>
> Norah Jones gmail.com> writes:
>
> >
> > For example:
> > a=[-15,-30,-10,1,3,5]
> > I want to find a negative and a positive minimum.
> > example: negative
> > print(min(a)) = -30
> > positive
> > print(min(a)) = 1
> >
> >
> >
>
> try t
On 3/12/2013 1:03 PM, Norah Jones wrote:
For example:
a=[-15,-30,-10,1,3,5]
I want to find a negative and a positive minimum.
example: negative
print(min(a)) = -30
positive
print(min(a)) = 1
If this is homework, stop reading and do it yourself ;-)
Otherwise...
>>> min(i for i in a if i >0)
1
> min(a)
This does not return a negative minimum on input [1] (because there is none).
> and
>
> min([e for e in a if e >=0]
This does not return a positive minimum on input [0] (because there is none).
I would have said:
pos_min = min(e for e in a if e > 0)
neg_min = min(e for e in a
Norah Jones gmail.com> writes:
>
> For example:
> a=[-15,-30,-10,1,3,5]
> I want to find a negative and a positive minimum.
> example: negative
> print(min(a)) = -30
> positive
> print(min(a)) = 1
>
>
>
try this:
min(a) => -30
min([n for n in a if i>0]) => 1
of course, you have to figur
- Original Message -
> For example:
> a=[-15,-30,-10,1,3,5]
> I want to find a negative and a positive minimum.
> example: negative
> print(min(a)) = -30
> positive
> print(min(a)) = 1
> --
> http://mail.python.org/mailman/listinfo/python-list
min(a)
and
min([e for e in a if e >=0]
For example:
a=[-15,-30,-10,1,3,5]
I want to find a negative and a positive minimum.
example: negative
print(min(a)) = -30
positive
print(min(a)) = 1
--
http://mail.python.org/mailman/listinfo/python-list
17 matches
Mail list logo