David Isaac wrote:
> 2. Is this a good argmax (as long as I know the iterable is finite)?
> def argmax(iterable): return max(izip( iterable, count() ))[1]

In Python 2.5:

Python 2.5a2 (trunk:46491M, May 27 2006, 14:43:55) [MSC v.1310 32 bit 
(Intel)] on win32
 >>> iterable = [5, 8, 2, 11, 6]
 >>> import operator
 >>> max(enumerate(iterable), key=operator.itemgetter(1))
(3, 11)


STeVe
-- 
http://mail.python.org/mailman/listinfo/python-list
  • Re: argmax Steven Bethard

Reply via email to