mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
Split std files
This commit is contained in:
parent
d38bdd9843
commit
2051692350
8 changed files with 187 additions and 173 deletions
12
compiler/erg_compiler/lib/std/_erg_nat.py
Normal file
12
compiler/erg_compiler/lib/std/_erg_nat.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from _erg_result import Error
|
||||
|
||||
class Nat(int):
|
||||
def try_new(i: int): # -> Result[Nat]
|
||||
if i >= 0:
|
||||
return Nat(i)
|
||||
else:
|
||||
return Error("Nat can't be negative")
|
||||
|
||||
def times(self, f):
|
||||
for _ in range(self):
|
||||
f()
|
Loading…
Add table
Add a link
Reference in a new issue