This commit is contained in:
Shunsuke Shibayama 2023-03-07 09:49:59 +09:00
parent f7fb06e10a
commit c5848db951
5 changed files with 47 additions and 5 deletions

View file

@ -37,6 +37,10 @@ class Int(int):
return then__(int.__pow__(self, other), Int)
def __rpow__(self, other):
return then__(int.__pow__(other, self), Int)
def __pos__(self):
return self
def __neg__(self):
return then__(int.__neg__(self), Int)
class IntMut(): # inherits Int
value: Int
@ -102,6 +106,10 @@ class IntMut(): # inherits Int
return IntMut(self.value ** other)
else:
return IntMut(self.value ** other.value)
def __pos__(self):
return self
def __neg__(self):
return IntMut(-self.value)
def inc(self, i=1):
self.value = Int(self.value + i)
def dec(self, i=1):