Fixed PSTL construction
This commit is contained in:
parent
d5985406ad
commit
eda63fd6f0
3 changed files with 38 additions and 30 deletions
20
stl/ast.py
20
stl/ast.py
|
|
@ -97,7 +97,13 @@ class Var(namedtuple("Var", ["coeff", "id"])):
|
|||
__slots__ = ()
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.coeff}*{self.id}"
|
||||
if self.coeff == -1:
|
||||
coeff_str = "-"
|
||||
elif self.coeff == +1:
|
||||
coeff_str = ""
|
||||
else:
|
||||
coeff_str = f"{self.coeff}*"
|
||||
return f"{coeff_str}{self.id}"
|
||||
|
||||
|
||||
class Interval(namedtuple('I', ['lower', 'upper'])):
|
||||
|
|
@ -217,3 +223,15 @@ class Next(namedtuple('Next', ['arg']), AST):
|
|||
def __hash__(self):
|
||||
# TODO: compute hash based on contents
|
||||
return hash(repr(self))
|
||||
|
||||
|
||||
class Param(namedtuple('Param', ['name']), AST):
|
||||
__slots__ = ()
|
||||
|
||||
def __repr__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
def __hash__(self):
|
||||
# TODO: compute hash based on contents
|
||||
return hash(repr(self))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue