From 5d891505ebad8007c99441b72b19a119dcc0ab9a Mon Sep 17 00:00:00 2001 From: Didictateur Date: Sat, 14 Feb 2026 21:59:27 +0100 Subject: [PATCH] first template --- legrandchien.py | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ main.py | 7 +++++ 2 files changed, 76 insertions(+) create mode 100644 legrandchien.py create mode 100644 main.py diff --git a/legrandchien.py b/legrandchien.py new file mode 100644 index 0000000..056b0da --- /dev/null +++ b/legrandchien.py @@ -0,0 +1,69 @@ +from enum import Enum +import numpy as np + +class Operation(Enum): + VAR = 1 + CONST = 2 + ADD = 3 + SUB = 4 + MULT = 5 + DIV = 6 + EXP = 7 + +# const class +class Const: + def __init__(self, value) -> None: + self.value = value + self.type = "Const" + + def __add__(self, other): + if other.type == "Const": + return Equation( + Operation.CONST, + None, + None, + self.value + ) + Equation( + Operation.CONST, + None, + None, + other.value + ) + if other.type == "Var": + return Equation( + Operation.CONST, + None, + None, + self.value + ) + Equation( + Operation.VAR, + None, + None, + other.name + ) + if other.type == "Equation": + return Equation( + Operation.CONST, + None, + None, + self.value + ) + other + +# var class +class Var: + def __init__(self, name) -> None: + self.name = name + self.type = "Var" + +# equation class +class Equation: + def __init__(self, op, left, right, value): + self.op = op + self.left = left + self.right = right + self.value = value + self.type = "Equation" + + def __add__(self, other): + if other.type == "Equation": + return Equation(Operation.ADD, self, other, None) diff --git a/main.py b/main.py new file mode 100644 index 0000000..0a8f06e --- /dev/null +++ b/main.py @@ -0,0 +1,7 @@ +from legrandchien import * + +if __name__ == "__main__": + k = Const(3) + kk = Const(4) + + eq = k + kk