Implement some primitive types methods

This commit is contained in:
Shunsuke Shibayama 2022-11-27 16:35:50 +09:00
parent 1a9ae3349d
commit 9ac8248609
3 changed files with 39 additions and 0 deletions

View file

@ -10,3 +10,9 @@ class Nat(int):
def times(self, f):
for _ in range(self):
f()
def saturating_sub(self, other: Nat):
if self > other:
return self - other
else:
return 0