Shannon -jj Behrens wrote:

Agreed!  Merry Christmas to everyone!

Here is my gift to you all:  write a function that acts like max, but
instead of returning the item in the list, return the index of the
item....

Puzzles!

def maxindex(seq):
    return max(zip(seq, itertools.count()))[1]


wasn't that fun?

If you want more, write a min function in the same way, but be sure
you don't duplicate any code. :)

Hmm... well, going for complex rather than terse...

def minindex(seq, index=0):
    if len(seq) == index+1:
        return index
    rest = minindex(seq, index+1)
    return rest if seq[rest] < seq[index] else index



--
Ian Bicking | [EMAIL PROTECTED] | http://blog.ianbicking.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to