mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-30 04:44:44 +00:00
Implement some primitive types methods
This commit is contained in:
parent
1a9ae3349d
commit
9ac8248609
3 changed files with 39 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue