Add files via upload
This commit is contained in:
parent
299fc1a058
commit
1e5113b208
17 changed files with 632 additions and 0 deletions
34
python_symb/symbols.py
Normal file
34
python_symb/symbols.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
from __future__ import annotations
|
||||
# from expr import Expr
|
||||
|
||||
|
||||
class Symbols:
|
||||
"""
|
||||
All maths things (other than number) that will be parsed need to be of "Symbols" class
|
||||
"""
|
||||
instances = []
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
Symbols.instances.append(self)
|
||||
|
||||
def __repr__(self):
|
||||
return self.name
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Var(Symbols):
|
||||
"""
|
||||
variable, like 'x' in x+2
|
||||
"""
|
||||
instances = []
|
||||
|
||||
def __init__(self, name):
|
||||
super().__init__(name)
|
||||
self.__class__.instances.append(self)
|
||||
|
||||
"""def __add__(self, other) -> Expr:
|
||||
return Expr('+', [self, other])"""
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue