Alex Martelli wrote:
> <[EMAIL PROTECTED]> wrote:
>    ...
> > thanks. I don't know what max can or cannot compare.
>
> Just the same things that you can compare with, say, < .
>
> I believe in 2.5 max and min will also accept a key= argument (like
> sorted etc) to tweak what to compare, so max(thelist, key=f) should then
> work (but in 2.4 you do need to more explicitly use some kind of
> decorate-sort-undecorate idiom, as explained in previous posts).
>
Thanks. In that case, would it be easier to understand(beside the
original iterative loop) if I use reduce and lambda ?

reduce(lambda (mv,mx), (v,x): mv > v and (mv,mx) or (v,x), ((f(x), x)
for x in mylist)))

As while DSU is a very smart way to guard the max compare thing, it is
still being introduced as a way that is not related to the original
problem, i.e. I just want to compare f(x)

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to