This commit is contained in:
Shunsuke Shibayama 2022-11-27 20:24:11 +09:00
parent 1a9ae3349d
commit 111a9f5615
23 changed files with 213 additions and 97 deletions

View file

@ -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