Created
July 24, 2014 17:22
-
-
Save sansarun/c9f0b0123f7a42446f71 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def min(*args, **kwargs): | |
key = kwargs.get("key", None) | |
iterable = args if len(args) > 1 else list(args[0]) | |
minValue = iterable[0] | |
for e in iterable: | |
if (e if not key else key(e)) < (minValue if not key else key(minValue)): | |
minValue = e | |
return minValue | |
def max(*args, **kwargs): | |
key = kwargs.get("key", None) | |
iterable = args if len(args) > 1 else list(args[0]) | |
maxValue = iterable[0] | |
for e in iterable: | |
if (e if not key else key(e)) > (maxValue if not key else key(maxValue)): | |
maxValue = e | |
return maxValue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment