mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
...
This commit is contained in:
parent
6d6c2935f4
commit
4cd84bbada
@ -11,6 +11,9 @@ def max(*args, key=None):
|
|||||||
raise TypeError('max expected 1 arguments, got 0')
|
raise TypeError('max expected 1 arguments, got 0')
|
||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
args = args[0]
|
args = args[0]
|
||||||
|
if len(args) == 2:
|
||||||
|
a, b = args
|
||||||
|
return a if key(a) > key(b) else b
|
||||||
args = iter(args)
|
args = iter(args)
|
||||||
res = next(args)
|
res = next(args)
|
||||||
if res is StopIteration:
|
if res is StopIteration:
|
||||||
@ -30,6 +33,9 @@ def min(*args, key=None):
|
|||||||
raise TypeError('min expected 1 arguments, got 0')
|
raise TypeError('min expected 1 arguments, got 0')
|
||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
args = args[0]
|
args = args[0]
|
||||||
|
if len(args) == 2:
|
||||||
|
a, b = args
|
||||||
|
return a if key(a) < key(b) else b
|
||||||
args = iter(args)
|
args = iter(args)
|
||||||
res = next(args)
|
res = next(args)
|
||||||
if res is StopIteration:
|
if res is StopIteration:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user