Skip to content

Instantly share code, notes, and snippets.

@samstewart
Created November 13, 2011 22:39

Revisions

  1. Sam Stewart created this gist Nov 13, 2011.
    10 changes: 10 additions & 0 deletions min_max_list.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    #Gets the index of maximum element in a list. If a conflict occurs, the index of the last largest is returned
    def maxl(l): return l.index(reduce(lambda x,y: max(x,y), l))

    #Gets the index of minimum element in a list. If a conflict occurs, the index of the last smallest is returned
    def minl(l): return l.index(reduce(lambda x,y: min(x,y), l))

    #same as above but without the reduce coolness
    def maxl(l): return l.index(max(l))

    def minl(l): return l.index(min(l))