Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Duck typing solution in Clear category for Min and Max by DiZ
def compare(args, key, operator):
try:
iterator = iter(*args)
except TypeError:
iterator = iter(args)
m = next(iterator)
k_m = key(m)
for i in iterator:
k_i = key(i)
if operator(k_i, k_m):
m, k_m = i, k_i
return m
def min(*args, key=lambda x:x):
return compare(args, key, lambda x,y:xy)
May 9, 2014
Comments: