mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
Fix #247
This commit is contained in:
parent
1a9ae3349d
commit
111a9f5615
23 changed files with 213 additions and 97 deletions
|
@ -1,7 +1,7 @@
|
|||
from _erg_result import Error
|
||||
|
||||
class Nat(int):
|
||||
def try_new(i: int): # -> Result[Nat]
|
||||
def try_new(i): # -> Result[Nat]
|
||||
if i >= 0:
|
||||
return Nat(i)
|
||||
else:
|
||||
|
@ -10,3 +10,9 @@ class Nat(int):
|
|||
def times(self, f):
|
||||
for _ in range(self):
|
||||
f()
|
||||
|
||||
def saturating_sub(self, other):
|
||||
if self > other:
|
||||
return self - other
|
||||
else:
|
||||
return 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue